Mapping object to dictionary and vice versa

To take a dictionary and convert it to an object and vice versa: public static class ObjectExtensions { public static T ToObject(this IDictionary source) where T : class, new() { T someObject = new T(); Type someObjectType = someObject.GetType(); foreach (KeyValuePair item in source) { someObjectType.GetProperty(item.Key).SetValue(someObject, item.Value, null); } return someObject; } public static IDictionary[…]

Convert a delimited string to a dictionary

Given a string of the format “key1=value1;key2=value2;key3=value3;” how to convert this to a dictionary: var dict = text.Split(new[] {‘;’}, StringSplitOptions.RemoveEmptyEntries) .Select(part => part.Split(‘=’)) .ToDictionary(split => split[0], split => split[1]); This will fail if the assumptions aren’t met. For example, an IndexOutOfRangeException could be thrown if the text isn’t in the right format and an ArgumentException[…]

Azure Key Vault AcquireTokenAsync Deadlocked

When calling AcquireTokenAsync to retrieve KeyVault credentials the process can become deadlocked if the call is not async’d all the way down the call stack. See the following SO post for the answer as to why: http://stackoverflow.com/questions/32594642/azure-keyvault-active-directory-acquiretokenasync-timeout-when-called-asynchrono

Speed up Visual Studio 2013

A number of ideas to speed up VS 2013, not sure if they work in 2015 yet: Clean the WebSiteCache folder (you may find it at C:\Users\%USERNAME%\AppData\Local\Microsoft\WebSiteCache) Clean the “Temporary ASP.NET Files” folder (find it at (C:\Windows\Microsoft.NET\Framework64\v4.0.30319) Restart Visual Studio Some links: https://blogs.msdn.microsoft.com/visualstudioalm/2015/03/03/make-debugging-faster-with-visual-studio/ http://blog.geocortex.com/2007/12/07/slow-visual-studio-performance-solved/ http://rdingwall.com/2009/08/24/does-your-visual-studio-run-slow/ A SO post on the subject: http://stackoverflow.com/questions/19617670/why-vs-2013-is-very-slow