Fast run time emitting with dynamic methods in .NET

It was a long time since, I have blogged. Nevertheless, I did not loose the enthusiasm to share the interesting stuff that I face. As component software developer, you should know how to access the properties of data source, when you create bound able controls (such as list control, combo box control or even grid control). The performance has always been a issue due to the fact that the control should work with any type of data source (ex.

How to prevent memory leaks when we are using events?

In the average development lifecycle is possible that event handlers that are attached to events of sources to not be destroyed in coordination with the listener object that attached the handler to the source. This can lead to memory leaks. The developers to take care about memory management not only when they use unmanaged resources but also when they attach new event handlers to specified event. This problem was solved by Microsoft in Windows Presentation Foundation.
Tags# , ,

ADO.NET XmlSerialization of extended DataTable

We are migrating communication protocol from .NET Remoting to WCF. Due to legacy fo this project, domain object is a DataTable that has some additional fields. In .NET Remoting serialization of that kind of object works perfectly, but in WCF these additional fields are not serialized. Instead of binary serialization in .NET Remoting, XML serialization is used in WCF. Lets have a class that derives DataTable type: public class WcfDataTable : DataTable { private string _ServerName; public WcfDataTable() : base() { } public WcfDataTable(string tableName) : base(tableName) { } public string ServerName { get { return this.
Tags# , , , ,

LINQ to SQL: Create generic method to load entity by primary key

Scenario We are implementing our data access layer based on LINQ TO SQL. In the specifications that were created by our software architect is required to have generic method that load from the data base any record into entity object by primary key. public class LINQGateway<TEntity> where TEntity : class { private IDbConnection _DbConnection; public LINQGateway(IDbConnection connection) { this._DbConnection = connection; } public TEntity GetEntityByPrimaryKey(object pkKey, params object[] pkKeys) { // TO DO } } Problem Every table has different primary key (count, name and data type of the primary key columns).
Tags# , , ,

Funny C# code

Even though I don’t know the author of the lines below I would say “Thank you man. You made day”. try { HOME: do { Play(“World of Warcraft”); } while (!asleep); Thread.Sleep(12 * 60 * 60 * 1000); WakeUp(coffee); if (you_still_give_a_shit()) goto WORK; else goto OUT; WORK: do { if (got_something_to_do()) { LookAtTheMonitor(); Press_Some_Keys(new string[] { “Ctrl+C”, “Ctrl+V” }); } Browse(“”); Browse(“”); Browse(“”); Have_a_Break(); Have_a_Kitkat(); } while (DateTime.Now.Hour < 5); if (DateTime.
Tags# , , , ,