In some case you want to create and Object from JSON, a great way of doing this to deserialize this JSON to an ExpandoObject. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 /// <summary> /// Convert Json String to an Expando Object /// </summary> /// <param name="that">Json string to convert</param> /// <returns>Expando Object</returns> public static ExpandoObject ToExpando ( this string that) { ExpandoObject result; try { result = JsonConvert.DeserializeObject<ExpandoObject>(that, new ExpandoObjectConverter()); } catch (Exception e) { throw e; } return result; } Here we use JsonConvert.DeserializeObject, you need to add reference to NewtonSoft.Json see below. 1 2 3 using Newtonsoft.Json ; using Newtonsoft.Json.Converters ; using Newtonsoft.Json.Linq ;
Put this in App.config to make the default style method name underscores: <specFlow> <trace stepDefinitionSkeletonStyle= "MethodNameUnderscores" /> </specFlow>
As a developer we normally maintain our own framework, our own abstraction of things, be it database wrappers, our own implementations of persistence managers, in some cases we figure out a better way or new way of doing things so we decide to include it in the framework, how do we now tell other developers to use this instead of the old one? The answer is the Obsolete Attribute. 1 2 3 4 5 6 7 8 9 [Obsolete("ExpandoObject.CreateObject is deprecated, please use NameValueCollection.CreateObject instead.", true)] public static void CreateObject ( this ExpandoObject that, NameValueCollection querystring) { querystring.AllKeys.ToList().ForEach(x => { if (!that.ToDictionary(y => y.Key).ContainsKey(x)) ((IDictionary< string , object >)that)[x] = querystring[x]; }); } We simply add this attribute on top of the method or class and specify our message. BTW, the Boolean parameter if set to True, will throw and exceptio...
Comments