public override object Deserialize( IDictionary <string, object> dictionary, Type type, System.Web.Script.Serialization.JavaScriptSerializer serializer) { if (dictionary == null) { throw new ArgumentNullException("dictionary"); } if (type == typeof(Florine.NutrientSet)) { // Create the instance to deserialize into. Florine.NutrientSet ns = new Florine.NutrientSet(); // Deserialize the ListItemCollection's items. System.Collections.ArrayList itemsList = (System.Collections.ArrayList)dictionary["Nutrients"]; foreach (object o in itemsList) { Dictionary <string, object> itm = serializer.ConvertToType <Dictionary <String, object> >(o); ns[serializer.ConvertToType <Florine.Nutrient>(itm["n"])] = serializer.ConvertToType <double>(itm["v"]); //list.Add(serializer.ConvertToType<ListItem>(itemsList[i])); } return(ns); } return(null); }
public override object Deserialize( IDictionary <string, object> dictionary, Type type, System.Web.Script.Serialization.JavaScriptSerializer serializer) { if (dictionary == null) { throw new ArgumentNullException("dictionary"); } if (type == typeof(JSONIPage)) { JSONIPage np = new JSONIPage(); np.MainType = serializer.ConvertToType <GameState.PageType>( dictionary["MainType"] ); np.SubType = serializer.ConvertToType <GameState.PageSubType>( dictionary["SubType"] ); if (dictionary.Keys.Contains("AppliedOptions")) { np.AppliedOptions = new JSONIOptionSet() { }; System.Collections.ArrayList lst = serializer.ConvertToType <System.Collections.ArrayList>( dictionary["AppliedOptions"] ); if (lst != null) { foreach (object i in lst) { if (i is IGameOption) { np.AppliedOptions.Add(serializer.ConvertToType <IGameOption>(i)); } else { foreach (object o in serializer.ConvertToType <ArrayList>(i)) { //List<IGameOption> np.AppliedOptions.Add(serializer.ConvertToType <IGameOption>(o)); } } } } } return(np); } return(null); }