Geeks With Blogs

News My Blog has been moved to

Post Categories

Michael Freidgeim's Blog My Blog has been moved to May 2013 Entries
AddIfNotNull collection extensions
I want to post a few recently created collection extensions to write in one line, what otherwise takes 2 or more public static void AddIfNotNull( this IList coll, T newItem) where T : class { if (newItem != null) { coll.Add(newItem); } } public static void AddRangeIfNotNullOrEmpty( this List coll, IEnumerable newItems) where T : class { if (!newItems.IsNullOrEmptySeq... { coll.AddRange(newItems); } } public static void AddIfNotContains( this Dictionary dictionary, TKey key, TValue value) { if ......

Posted On Saturday, May 25, 2013 10:20 AM

Override ToString() using Json serialization or something else.
When creating a new data class, it’s a good idea to override ToString() method to output most of the data.It will help to see details in logs.The only exception if the class has a sensitive data like CreditCard number or password.For DataContract classes just usepublic override string ToString() { //Use JSON as the simplest serializer string sRet = this.ToExtJsJsonItem(); return sRet; } Sometimes it is useful to create extensions to standard .Net classes.E.g. In CookieHelper class I've created public ......

Posted On Saturday, May 4, 2013 1:18 PM

Deploy PDB files into production to ease exception report investigation.
For a long time I believed that PDB as a part of debugging information should not be included in production deployment. Recently my colleague suggested to copy them to simplify exception investigations. The following SO discussion convinced us that it is a good idea ( at least for web sites). These files will not be exposed to the public if kept in the right places (website\bin). ......

Posted On Saturday, May 4, 2013 1:03 PM

Copyright © Michael Freidgeim | Powered by: | Join free