<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>C# on InternetException</title><link>https://internetexception.com/categories/c%23/</link><description>Recent content in C# on InternetException</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 06 Oct 2025 12:39:46 +0200</lastBuildDate><atom:link href="https://internetexception.com/categories/c%23/index.xml" rel="self" type="application/rss+xml"/><item><title>Disable Xunit Test on specific OS</title><link>https://internetexception.com/2025/10/04/disable-xunit-test-on-specific-os/</link><pubDate>Sat, 04 Oct 2025 22:51:15 +0200</pubDate><guid>https://internetexception.com/2025/10/04/disable-xunit-test-on-specific-os/</guid><description>&lt;p&gt;Lately I was having a problem with some of my tests causing problems for other developers on the project I am working on. They were using Windows for their development while I am using Debian for my work. The application that was being tested was not designed for non Unix system - now rarely anybody is hosting they production code on Windows Server - everybody is using Unix for .net.&lt;/p&gt;</description></item><item><title>Writing a simple C# source code generator with Fluent API</title><link>https://internetexception.com/2025/10/02/writing-simple-c-source-code-generator/</link><pubDate>Thu, 02 Oct 2025 16:05:39 +0200</pubDate><guid>https://internetexception.com/2025/10/02/writing-simple-c-source-code-generator/</guid><description>&lt;h1 id="introduction"&gt;Introduction&lt;/h1&gt;&#10;&lt;p&gt;Usually in .NET world when you want to write generic code you use generic method or classes. But sometimes it is still not enough when you want to automate some things. I.e. you want to dynamically register in &lt;a href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-9.0" target="_blank" rel="noopener noreferrer"&gt;DI&lt;/a&gt;&#10; all the classes that implements some interface. Probably, in this case, you would do something like that:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;implementations&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyClass&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Assembly&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Types&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetInterfaces&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IMyInterface&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;foreach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;implementations&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddScoped&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IMyInterface&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;implementation&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And it would be completely fine. Even if Reflection is pretty slow, your application would not be getting significantly slower because of that. Certainly you would not notice the slow down.&lt;/p&gt;</description></item><item><title>Dynamic runtime delegates conversion</title><link>https://internetexception.com/2017/05/07/dynamic-runtime-delegates-conversion/</link><pubDate>Sun, 07 May 2017 11:53:00 +0200</pubDate><guid>https://internetexception.com/2017/05/07/dynamic-runtime-delegates-conversion/</guid><description>&lt;h3 id="introduction"&gt;Introduction&lt;/h3&gt;&#10;&lt;p&gt;Delegates can be converted easily to another type if you know types of those delegates. But if you do not know it is impossible without really complicated code.&lt;/p&gt;</description></item><item><title>Automatic scrolling to edited text box in Xamarin Android.</title><link>https://internetexception.com/2017/02/25/automatic-scrolling-to-edited-text-box-in-xamarin-android/</link><pubDate>Sat, 25 Feb 2017 14:48:00 +0100</pubDate><guid>https://internetexception.com/2017/02/25/automatic-scrolling-to-edited-text-box-in-xamarin-android/</guid><description>&lt;p&gt;&lt;strong&gt;Important note: this should work well with newer version of Xamarin (2.3.3). If you cannot update for some reason this article will explain workaround.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h3 id="introduction"&gt;Introduction&lt;/h3&gt;&#10;&lt;p&gt;In previous article I explained how to detect show and hide events of software keyboard in Xamarin Android. I did it in my project because of the fact that some of text boxes was hidden by software keyboard that suppose to edit contents of those text boxes. In this article I will explain how to work around this issue in some older versions of Xamarin.&lt;/p&gt;</description></item><item><title>Detecting software keyboard events in Xamarin Android</title><link>https://internetexception.com/2017/02/03/detecting-software-keyboard-events-in-xamarin-android/</link><pubDate>Fri, 03 Feb 2017 23:31:00 +0100</pubDate><guid>https://internetexception.com/2017/02/03/detecting-software-keyboard-events-in-xamarin-android/</guid><description>&lt;h3 id="introduction"&gt;Introduction&lt;/h3&gt;&#10;&lt;p&gt;It is quite strange that you can&amp;rsquo;t easily detect if software keyboard is visible or not on Android. Because of that, it is also complicated thing to do in Xamarin.&lt;/p&gt;</description></item><item><title>Xamarin Android Services Pattern on GPS example</title><link>https://internetexception.com/2017/01/30/xamarin-android-services-pattern-on-gps-example/</link><pubDate>Mon, 30 Jan 2017 04:17:00 +0100</pubDate><guid>https://internetexception.com/2017/01/30/xamarin-android-services-pattern-on-gps-example/</guid><description>&lt;h3 id="introduction"&gt;Introduction&lt;/h3&gt;&#10;&lt;p&gt;In Xamarin if you want to use many Android native service/mechanism you have to implement it in Activity class. Or at least that is how Xamarin documentation wants you to do it.&lt;/p&gt;</description></item><item><title>Xamarin with TinyIoC</title><link>https://internetexception.com/2016/12/10/xamarin-with-tinyioc/</link><pubDate>Sat, 10 Dec 2016 09:48:00 +0100</pubDate><guid>https://internetexception.com/2016/12/10/xamarin-with-tinyioc/</guid><description>&lt;h3 id="introduction"&gt;Introduction&lt;/h3&gt;&#10;&lt;p&gt;This article is builds on topics and solutions introduces in &lt;a href="https://internetexception.com/2016/07/09/viewfactory-for-xamarin-application/"&gt;ViewFactory for Xamarin application&lt;/a&gt;&#10; and &lt;a href="https://internetexception.com/2016/04/24/xamarin-master-detail-page/"&gt;Xamarin Master-Detail Page&lt;/a&gt;&#10; articles. It shows method for easier navigation and use of services via IoC in Xamarin application. Knowledge from previous examples is not necessary, but makes this article bit easier to understand.&lt;/p&gt;</description></item><item><title>Genereting proxies during runtime using Reflection.Emit</title><link>https://internetexception.com/2016/10/07/genereting-proxies-during-runtime-using-reflection-emit/</link><pubDate>Fri, 07 Oct 2016 12:29:00 +0200</pubDate><guid>https://internetexception.com/2016/10/07/genereting-proxies-during-runtime-using-reflection-emit/</guid><description>&lt;p&gt;&lt;em&gt;Reflection.Emit&lt;/em&gt; is very powerful tool. It creates IL code and since C# is converted into IL too, we have the same functionality as in C# and even more. It is very powerful and at the same time very complicated. Because of that it is worth to discuss how and for what it should be used. One idea is to create dynamic code with automatic implementations of interfaces - proxy types.&lt;/p&gt;</description></item><item><title>Faster than Reflection: Delegates. Part 3.</title><link>https://internetexception.com/2016/09/02/faster-than-reflection-delegates-part-3/</link><pubDate>Fri, 02 Sep 2016 13:15:00 +0200</pubDate><guid>https://internetexception.com/2016/09/02/faster-than-reflection-delegates-part-3/</guid><description>&lt;p&gt;&lt;strong&gt;This is third article in series, that explains how to create delegates for public and non-public members of public, non-public or not known in compile-time types. If you are not familiar with previous articles and looking for detailed explanation of how delegates works, how they are created and why, I strongly encourage you to read first two. If you are just looking for a way to create delegates for methods or constructors it is not necessary.&lt;/strong&gt; Code with new features and with bug fixes is available on &lt;a href="https://github.com/npodbielski/Delegates" target="_blank" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&#10; and as &lt;a href="https://www.nuget.org/packages/DelegatesFactory/1.0.0" target="_blank" rel="noopener noreferrer"&gt;Nuget&lt;/a&gt;&#10; package.&lt;/p&gt;</description></item><item><title>Faster than Reflection: Delegates. Part 2.</title><link>https://internetexception.com/2016/08/16/faster-than-reflection-delegates-part-2/</link><pubDate>Tue, 16 Aug 2016 12:59:00 +0200</pubDate><guid>https://internetexception.com/2016/08/16/faster-than-reflection-delegates-part-2/</guid><description>&lt;p&gt;&lt;strong&gt;This is second article in series, that explains how to create delegates for public and non-public members of public, non-public or not known in compile-time types. If you are not familiar with previous article and looking for detailed explanation of how delegates works, how they are created and why, I strongly encourage you to read it first. If you are just looking for a way to create delegates for methods or constructors it is not necessary.&lt;/strong&gt; Last article in series you can find &lt;a href="https://internetexception.com/2016/09/02/faster-than-reflection-delegates-part-3/" title="Third part"&gt;here&lt;/a&gt;&#10;. Code with new features and with bug fixes is available on &lt;a href="https://github.com/npodbielski/Delegates" target="_blank" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&#10; and as &lt;a href="https://www.nuget.org/packages/DelegatesFactory/1.0.0" target="_blank" rel="noopener noreferrer"&gt;Nuget&lt;/a&gt;&#10; package. In previous &lt;a href="https://internetexception.com/2016/08/05/faster-than-reflection-delegates-part-1/"&gt;article&lt;/a&gt;&#10; and first one in series, we covered:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Static&#10;&lt;ol&gt;&#10;&lt;li&gt;Properties&lt;/li&gt;&#10;&lt;li&gt;Fields&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Instance&#10;&lt;ol&gt;&#10;&lt;li&gt;Properties&lt;/li&gt;&#10;&lt;li&gt;Fields&lt;/li&gt;&#10;&lt;li&gt;Indexers&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Now it is time to cover following members.&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Static&#10;&lt;ol&gt;&#10;&lt;li&gt;Methods&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Instance&#10;&lt;ol&gt;&#10;&lt;li&gt;Methods&lt;/li&gt;&#10;&lt;li&gt;Constructors&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;</description></item><item><title>Faster than Reflection: Delegates. Part 1.</title><link>https://internetexception.com/2016/08/05/faster-than-reflection-delegates-part-1/</link><pubDate>Fri, 05 Aug 2016 09:58:00 +0200</pubDate><guid>https://internetexception.com/2016/08/05/faster-than-reflection-delegates-part-1/</guid><description>&lt;p&gt;This article is first part of the series of three. Next ones you can find &lt;a href="https://internetexception.com/2016/08/16/faster-than-reflection-delegates-part-2/" title="Second part"&gt;here&lt;/a&gt;&#10; and &lt;a href="https://internetexception.com/2016/09/02/faster-than-reflection-delegates-part-3/" title="Third part"&gt;here&lt;/a&gt;&#10;. Code for all three articles, with new features and bug fixes is available on &lt;a href="https://github.com/npodbielski/Delegates" target="_blank" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&#10; and as &lt;a href="https://www.nuget.org/packages/DelegatesFactory/1.0.0" target="_blank" rel="noopener noreferrer"&gt;Nuget&lt;/a&gt;&#10; package.&lt;/p&gt;&#10;&lt;h3 id="why-not-reflection"&gt;Why not Reflection?&lt;/h3&gt;&#10;&lt;p&gt;If you working with .NET and C# (probably other languages too), at some point, you will have to write more advanced and generic code, that i.e. reads all properties of a type, searches for attributes, etc. Or maybe you want to call some private method or property? It is not that rare to use some internal mechanism of framework or library. Usually, the first solution involves Reflection. But the thing is: Reflection is slow. Of course, it is sufficient if you need to use Reflection rarely and it is not the main code of the application. If it is used more often at some point, you will probably try to optimize it. And now is the fun part: how to do it?&lt;/p&gt;</description></item><item><title>Xamarin Master-Detail Page</title><link>https://internetexception.com/2016/04/24/xamarin-master-detail-page/</link><pubDate>Sun, 24 Apr 2016 07:41:00 +0200</pubDate><guid>https://internetexception.com/2016/04/24/xamarin-master-detail-page/</guid><description>&lt;p&gt;This article as previous ones (&lt;a href="https://internetexception.com/2016/04/22/xamarin-frame-and-style-with-padding/"&gt;Frame With Padding&lt;/a&gt;&#10;, &lt;a href="https://internetexception.com/2016/04/22/xamarin-frame-and-disappearing-outline/"&gt;Frame Outline Problem&lt;/a&gt;&#10;, &lt;a href="https://internetexception.com/2016/04/22/xamarin-frame-and-disappearing-outline/"&gt;Inheritance from Implicit Styles&lt;/a&gt;&#10;) also will be about Xamarin. This time we will inspect Master-Detail page control/mechanism. You can find official documentation for this control &lt;a href="https://developer.xamarin.com/guides/xamarin-forms/user-interface/navigation/master-detail-page/" target="_blank" rel="noopener noreferrer"&gt;here&lt;/a&gt;&#10;. Quick spoiler: I never used this in any production application. Why? I will explain. Whole article will be to explain why this is just not worth your time. In this and subsequent articles I will introduce much better solution.&lt;/p&gt;</description></item><item><title>Xamarin Style based on implicit Style</title><link>https://internetexception.com/2016/04/22/xamarin-style-based-on-implicit-style/</link><pubDate>Fri, 22 Apr 2016 23:17:00 +0200</pubDate><guid>https://internetexception.com/2016/04/22/xamarin-style-based-on-implicit-style/</guid><description>&lt;p&gt;Next article about bugs in Xamarin will touch topic of Styles. Styles for all of controls not only Frame (and if you wondering why Frame you should check first two articles about Xamarin &lt;a href="https://internetexception.com/2016/04/22/xamarin-frame-and-style-with-padding/" title="Xamarin Frame and Style with Padding"&gt;here&lt;/a&gt;&#10; and &lt;a href="https://internetexception.com/2016/04/22/xamarin-frame-and-disappearing-outline/" title="Xamarin Frame and disappearing Outline"&gt;here)&lt;/a&gt;&#10;. First of all if you are using Styles in Xamarin you probably know how to define implicit styles. If not here is a sample:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-xml" data-lang="xml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;&amp;lt;Application.Resources&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;ResourceDictionary&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;Style&lt;/span&gt; &lt;span class="na"&gt;TargetType=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;Label&amp;#34;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;Setter&lt;/span&gt; &lt;span class="na"&gt;Property=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;FontSize&amp;#34;&lt;/span&gt; &lt;span class="na"&gt;Value=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;45&amp;#34;&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;/Style&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;/ResourceDictionary&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;&amp;lt;/Application.Resources&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Xamarin Frame and disappearing Outline</title><link>https://internetexception.com/2016/04/22/xamarin-frame-and-disappearing-outline/</link><pubDate>Fri, 22 Apr 2016 13:00:00 +0200</pubDate><guid>https://internetexception.com/2016/04/22/xamarin-frame-and-disappearing-outline/</guid><description>&lt;p&gt;This is another article in mini series of Xamarin bugs and workarounds for them :) Previous one you can find &lt;a href="https://internetexception.com/2016/04/22/xamarin-frame-and-style-with-padding/" title="Xamarin Frame and Style with Padding"&gt;here&lt;/a&gt;&#10;. This one is again about Frame control. I promise that another one will be about something else B) Issue can be observed when you bind BackgroundColor property of Frame control and something will trigger change of view model source property binded to background color.&lt;/p&gt;</description></item><item><title>Xamarin Frame and Style with Padding</title><link>https://internetexception.com/2016/04/22/xamarin-frame-and-style-with-padding/</link><pubDate>Fri, 22 Apr 2016 05:10:00 +0200</pubDate><guid>https://internetexception.com/2016/04/22/xamarin-frame-and-style-with-padding/</guid><description>&lt;p&gt;If you are a bit advanced with Xamarin you should already now that there is possibility of styling your controls almost like in WPF. Almost, because there is a few strange bugs involving this. For example there is a problem with styling a Padding property in Frame. Consider following Xaml of Xamarin application (I tested it in Android):&lt;/p&gt;</description></item><item><title>Safe cast string to enum</title><link>https://internetexception.com/2014/02/25/safe-cast-string-to-enum-2/</link><pubDate>Tue, 25 Feb 2014 23:49:00 +0100</pubDate><guid>https://internetexception.com/2014/02/25/safe-cast-string-to-enum-2/</guid><description>&lt;p&gt;In on of my projects I had make an interface between database and web service in C# code. One of problem I had to face was need to cast strings to enumerable types, because of simple fact that database have no idea what is an &amp;rsquo;enum&amp;rsquo;. Yes simplest mapping between an enumeration and database type is integer. It is simplest but in my idea not best. For example I really do not remember (or do not WANT to remember) what is the meaning of 4 integer value in case of package shipment status.&lt;/p&gt;</description></item><item><title>Smart string builder</title><link>https://internetexception.com/2014/02/22/smart-string-builder/</link><pubDate>Sat, 22 Feb 2014 03:16:00 +0100</pubDate><guid>https://internetexception.com/2014/02/22/smart-string-builder/</guid><description>&lt;p&gt;In this rare times when I was writing code that suppose to create large string from smaller chunks and with some non string parameters I was using &lt;strong&gt;StringBuilder&lt;/strong&gt; class of course. Of course because string adding, or string concatenation is very costly when talking about memory utilization. It is because every time you do this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#34;Hello world!&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;&amp;#34;n&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;&amp;#34;How are you?&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;new string is created for every &amp;lsquo;+&amp;rsquo; operation in memory. Not a best way of doing strings creations. &lt;code&gt;StringBuilder&lt;/code&gt; is better because it do not creates strings until you call &lt;strong&gt;.&lt;/strong&gt;&lt;code&gt;ToString&lt;/code&gt; method of &lt;code&gt;StringBuilder&lt;/code&gt; class.&lt;/p&gt;</description></item><item><title>Expression parsing and nested properties</title><link>https://internetexception.com/2014/02/22/expression-parsing-and-nested-properties/</link><pubDate>Sat, 22 Feb 2014 03:00:00 +0100</pubDate><guid>https://internetexception.com/2014/02/22/expression-parsing-and-nested-properties/</guid><description>&lt;p&gt;In one of projects I was working on, I needed to get property value from property path and property path from expression. First, lets cover second case. With expression in form of nested property value:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;()=&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;object1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;object2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;object3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;object4&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;we cannot take simple value of some property, because we have only root object, &lt;code&gt;object1&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Mapping collection of entities in EF with AutoMapper</title><link>https://internetexception.com/2013/05/25/mapping-collection-of-entities-in-ef-with-automapper/</link><pubDate>Sat, 25 May 2013 11:38:00 +0200</pubDate><guid>https://internetexception.com/2013/05/25/mapping-collection-of-entities-in-ef-with-automapper/</guid><description>&lt;p&gt;In my &lt;a href="https://internetexception.com/2013/05/16/entity-framework-and-base-entity-class/"&gt;last post&lt;/a&gt;&#10; I explained why is useful to add base entity class in EF. Today I will write how with use of this base class an AutoMapped map collection of data objects (i.e. DTOs to existing collection of entities).&lt;/p&gt;</description></item><item><title>Ninject and Entity Framework</title><link>https://internetexception.com/2013/05/03/ninject-and-entity-framework/</link><pubDate>Fri, 03 May 2013 03:50:00 +0200</pubDate><guid>https://internetexception.com/2013/05/03/ninject-and-entity-framework/</guid><description>&lt;p&gt;&lt;a href="https://internetexception.com/2013/04/23/entity-framework-patterns-extension-and-unit-test-in-visual-studio-2012/" target="_blank" rel="noopener noreferrer"&gt;Last time&lt;/a&gt; I wrote about problem with testing Entity Framework in Visual Studio 2012. During working on this project I also encounter problems with configuration of Ninject to allow injecting Entity Framework classes from its Patterns extension. To be frankly this was not much a problem then lack of documentation. I just was forced to experiment with Ninject and new-thing-for-me Entity Framework Patterns extension.&lt;/p&gt;</description></item><item><title>Using Matlab from C# application.</title><link>https://internetexception.com/2013/01/20/using-matlab-from-c-application/</link><pubDate>Sun, 20 Jan 2013 11:25:00 +0100</pubDate><guid>https://internetexception.com/2013/01/20/using-matlab-from-c-application/</guid><description>&lt;p&gt;While writing an application for my Masters degree diploma, I wrote a simple application that was using COM Matlab server. I have found it hard to use it mainly due to lack of documentation, which is really basic with only few code examples for C#. I guess writing programs that use Matlab for calculating is not encouraged by MathWorks, you would became competition that way :) Nonetheless, I accomplished why I was required to do, so I decided to share this with the rest of the world.&lt;/p&gt;</description></item><item><title>Server controls in separete assembly part 2</title><link>https://internetexception.com/2012/12/24/server-controls-in-separete-assembly-part-2/</link><pubDate>Mon, 24 Dec 2012 05:14:00 +0100</pubDate><guid>https://internetexception.com/2012/12/24/server-controls-in-separete-assembly-part-2/</guid><description>&lt;p&gt;&lt;a href="https://internetexception.com/2012/12/22/server-controls-in-separate-assembly/"&gt;Yesterday I was writing about creating server controls in separate assembly&lt;/a&gt;&#10;. Today I will cover more complicated example then simple &amp;ldquo;Hello World!&amp;rdquo; control. My goal was to create text box that will take handler method to run when validation event will be triggered, and when validation fail will show appropriate message. Text box with builtin validation would be nice, since &lt;a href="http://searchsoftwarequality.techtarget.com/tip/The-importance-of-input-validation" target="_blank" rel="noopener noreferrer"&gt;you always&lt;/a&gt;&#10; &lt;a href="http://www.ibm.com/developerworks/library/l-sp2/index.html" target="_blank" rel="noopener noreferrer"&gt;should&lt;/a&gt;&#10; &lt;a href="http://web.securityinnovation.com/appsec-weekly/blog/?Tag=Input%20and%20Data%20Validation" target="_blank" rel="noopener noreferrer"&gt;validate&lt;/a&gt;&#10; &lt;a href="http://www.securityninja.co.uk/secure-development/input-validation/" target="_blank" rel="noopener noreferrer"&gt;user input&lt;/a&gt;&#10;, right? But lets start creating our control.&lt;/p&gt;</description></item><item><title>Server controls in separate assembly</title><link>https://internetexception.com/2012/12/22/server-controls-in-separate-assembly/</link><pubDate>Sat, 22 Dec 2012 14:52:00 +0100</pubDate><guid>https://internetexception.com/2012/12/22/server-controls-in-separate-assembly/</guid><description>&lt;p&gt;In my project I wanted to create text box control with builtin configurable validation. ASP.NET definition in &lt;code&gt;.aspx&lt;/code&gt; or &lt;code&gt;.ascx&lt;/code&gt; file would get validation function by name. But I do not wanted to create just &lt;code&gt;.ascx&lt;/code&gt; file with text box. I could not then reuse that control in other projects and it certainly would be nice, right? Creating such server control from code is not hard, but maintainability of HTML code in C# (it cannot be done other way) is not good. It&amp;rsquo;s pain really. Why Microsoft would create way to automatically create C# code from &lt;code&gt;.ascx&lt;/code&gt;, &lt;code&gt;.aspx&lt;/code&gt; files is mystery for me.&lt;/p&gt;</description></item><item><title>Handling Ajax errors in ASP.NET</title><link>https://internetexception.com/2012/12/22/handling-ajax-errors-in-asp-net/</link><pubDate>Sat, 22 Dec 2012 09:58:00 +0100</pubDate><guid>https://internetexception.com/2012/12/22/handling-ajax-errors-in-asp-net/</guid><description>&lt;p&gt;Yesterday I wrote about &lt;a href="https://internetexception.com/2012/12/21/global-updatepanel-loading-indicator-in-asp-net/"&gt;issue with Ajax postbacks&lt;/a&gt;&#10; in application I am working currently. Problem was with buttons that was triggering &lt;code&gt;UpdatePanels&lt;/code&gt; to update asynchronously. After adding loading indicator I wanted to add error handling at client side.&lt;/p&gt;</description></item><item><title>Global UpdatePanel loading indicator in ASP.NET</title><link>https://internetexception.com/2012/12/21/global-updatepanel-loading-indicator-in-asp-net/</link><pubDate>Fri, 21 Dec 2012 10:48:00 +0100</pubDate><guid>https://internetexception.com/2012/12/21/global-updatepanel-loading-indicator-in-asp-net/</guid><description>&lt;p&gt;When I started working on application I am working right now, one of first things I noticed, that was not entirely wrong but was inconvenient: when user clicked on some button that triggers update panel you was not entirely sure it worked or not. Why? Because of three things:&lt;/p&gt;</description></item><item><title>Better algorithm for finding UpdatePanel that will be updated during page request.</title><link>https://internetexception.com/2012/12/13/better-algorithm-for-finding-updatepanel-that-will-be-updated-during-page-request/</link><pubDate>Thu, 13 Dec 2012 15:50:00 +0100</pubDate><guid>https://internetexception.com/2012/12/13/better-algorithm-for-finding-updatepanel-that-will-be-updated-during-page-request/</guid><description>&lt;p&gt;Other day I was experimenting with finding which &lt;a href="https://internetexception.com/2012/12/10/display-message-on-client-from-anywhere-in-code-with-asp-net/"&gt;UpdatePanel will be updated during page post back.&lt;/a&gt;&#10; I found out that my solution was not working correctly for complex triggers, like user controls with custom events, which will trigger async postbacks and update of panel. Or for grids with buttons. It was big issue. Also it was not pointing to correct &lt;code&gt;UpdatePanel&lt;/code&gt; if name of control was not entirely unique (for example when you have multiple same custom controls on page). It would return first panel, even if it wasn&amp;rsquo;t updating.&lt;/p&gt;</description></item><item><title>Display message on client from anywhere in code with ASP.NET</title><link>https://internetexception.com/2012/12/10/display-message-on-client-from-anywhere-in-code-with-asp-net/</link><pubDate>Mon, 10 Dec 2012 09:20:00 +0100</pubDate><guid>https://internetexception.com/2012/12/10/display-message-on-client-from-anywhere-in-code-with-asp-net/</guid><description>&lt;p&gt;When I was working with WinForms application in previous work I have found one of most useful feature, ability to show some message to the client. For example user cannot edit some entity in particular time (it is being edited by someone else) or should change password because it will expire in x days. I wanted to do something similar in my web application.&lt;/p&gt;</description></item><item><title>Getting private field or property from object</title><link>https://internetexception.com/2012/12/09/getting-private-field-or-property-from-object/</link><pubDate>Sun, 09 Dec 2012 07:26:00 +0100</pubDate><guid>https://internetexception.com/2012/12/09/getting-private-field-or-property-from-object/</guid><description>&lt;p&gt;Yesterday I was playing with finding all &lt;code&gt;UpdatePanel&lt;/code&gt; controls on page during generating response in ASP.NET. Since object with this information is private itself and collection of panels is private in that object, I had to write some code to extract that data. I ended up with to extension methods for &lt;code&gt;Object&lt;/code&gt; type, for getting private field an private property. It&amp;rsquo;s pretty straightforward, besides one thing: since member is private. And we don&amp;rsquo;t know in witch type exactly (every type in base/descendant hierarchy have it&amp;rsquo;s one private members) we have to search them all. So this is final code:&lt;/p&gt;</description></item></channel></rss>