Archive for the '.NET' Category

C# Perf improvement data types or using Linq is faster?

Wednesday, February 13th, 2013

Recently I was asked a simple code to improve the performance, and at first I couldn’t see it but as you know your brain starts working when you aren’t thinking of the problem anymore. (It happen to me when I was driving) Anyway the problem on hand was there is a for loop and when [...]

Share

Using LINQ to refactoring code into single responsibility principle SRP

Thursday, January 24th, 2013

Was going through some legacy code recently and found a big for loop that had multiple switch statement inside. So being that I hate something that is fairly large, every method should be small and concise, I went along to refactor it. This code is generic so you might see something like this in your [...]

Share

Using Linq to refactor code

Monday, December 17th, 2012

Here is some poorly written code that I had to review today and modify. I have removed the domain of the code and renamed the variables, so that it remains anonymous, but the just of the code is still intact. ?View Code CSHARP1 2 3 4 5 6 7 8 9 10 11 12 13 [...]

Share

C# detect inuktitut characters Canadian Aboriginal Syllabics

Tuesday, November 6th, 2012

Here is a quick way to detect if a text is in Canadian Aboriginal Syllabic in C#. It is just an extension method that would detect if your string is in that range by using regex. ?View Code CSHARP1 2 3 4 5 6 7 8 9 10 11 12 13 14 15   public [...]

Share

Command Pattern with Notification Event Delegates

Monday, September 19th, 2011

Here is a nice little code I did recently, where the Command Pattern is used with a notification observer like pattern. First of the Command Pattern, a simple interface for task with an execute method ?View Code CSHARP1 2 3 4 5 6 7 public interface ITask { /// <summary> /// Execute the task /// [...]

Share

Building an installer and displaying Data Link Properties Dialog Box for connection string

Wednesday, July 20th, 2011

So was hacking a new installer and wanted to display the data link properties dialog, for building a connection string. Here is what I have found out by playing with it. One has to add the reference to ADODB.DLL (from .NET reference) and Microsoft OLE DB Service Component 1.0 Type Library from the COM tab [...]

Share

NET 4, VS2010 install fails on XP SP3 machine “Fatal error during installation”

Tuesday, April 12th, 2011

So I had this issue at work had to install on xp machine, dont ask why but just had to Thus I was stuck installing vs2010, I went and downloaded .net 4 standalone And was having the same issues. And went through the logs and found the error message was due a registry key (aren’t [...]

Share

My talk on WatiN , SpecFlow, BDD, Code and additional material

Saturday, April 2nd, 2011

Thanks to everyone who came out for the Ottawa .Net Community talk yesterday, I had a blast. I would like to thank everyone who came out for the talk. Here is my presentation WatiN – Web Application Testing on Prezi You can find the code on github https://github.com/taswar/ODNC-WatiN-And-SpecFlow-Demo-Code Additional Resources Here are some additional information [...]

Share

Automapper: Mapping Objects Part 7 of 7 (Startup Registration)

Tuesday, March 15th, 2011

In this last part of the series I wanted to talk about how to register automapper at startup of your web application, in doing so it would help speed things up with automapper. There are many ways to do it, the easiest way is to just have a method inside Global.asax.cs file in your Application_Start [...]

Share

Automapper: Mapping objects Part 6 of 7 (CustomFormatter)

Monday, March 14th, 2011

In this part I will show how we can use a customer value formatter to format our mapped data into single “Number of Order:” and plural “Number of Orders:”. First the Domain and Dto (data transfer object) ?View Code CSHARP1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [...]

Share