public static void ReGenHashJsonTable(IDictionary input, ref Dictionary <string, object> output, string prefix) { IDictionaryEnumerator enumerator = input.GetEnumerator(); while (enumerator.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)enumerator.Current; string dType = entry.Value.GetType().ToString(); if (dType == "System.Collections.Generic.Dictionary`2[System.String,System.Object]" || dType == "Prime31.JsonObject") { if (string.IsNullOrEmpty(prefix)) { ReGenHashJsonTable((IDictionary)entry.Value, ref output, entry.Key.ToString()); } else { ReGenHashJsonTable((IDictionary)entry.Value, ref output, prefix + ":" + entry.Key); } } else if (entry.Value is string || entry.Value is bool || entry.Value is Boolean || entry.Value is byte || entry.Value is Byte || entry.Value is int || entry.Value is Int16 || entry.Value is Int32 || entry.Value is Int64 || entry.Value is long || entry.Value is float || entry.Value is decimal || entry.Value is double || entry.Value is Single || entry.Value is Double) { if (string.IsNullOrEmpty(prefix)) { output.Add(entry.Key.ToString(), entry.Value.ToString()); } else { output.Add(prefix + ":" + entry.Key, entry.Value.ToString()); } } else { MyDebug.Info("type \"" + dType + "\" is for Key: " + entry.Key + " : " + Json.encode(entry.Value.ToString()) ); } } }
static void ParseJSonString(IDictionary input, ref JsonObject output) { IDictionaryEnumerator enumerator = input.GetEnumerator(); if (null == output) { output = new JsonObject(); } while (enumerator.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)enumerator.Current; if (entry.Value.GetType().ToString() == "System.Collections.Generic.Dictionary`2[System.String,System.Object]") { ParseJSonString((IDictionary)entry.Value, ref output); } else if (entry.Value is string || entry.Value is bool || entry.Value is Boolean || entry.Value is byte || entry.Value is Byte || entry.Value is int || entry.Value is Int16 || entry.Value is Int32 || entry.Value is Int64 || entry.Value is long || entry.Value is float || entry.Value is decimal || entry.Value is double || entry.Value is Single || entry.Value is Double) { output.Add(entry.Key.ToString(), entry.Value); } else if (entry.Value is Array || entry.Value is ArrayList) { MyDebug.Info(entry.Key + " has array or list data Not implimented this function yet"); //output.Add(dictionaryEntry.Key.ToString(), dictionaryEntry.Value.ToString()); } else { MyDebug.Info(entry.Key + " has unidentified type"); } } }
// public void AddObserver(Component observer, String name) { //MyDebug.Log("Function: " + name + ", added for " + observer.name); if (string.IsNullOrEmpty(name)) { MyDebug.Info("NotificationCenter::AddObserver => empty name specificed for method in AddListener."); return; } if (_listnersData.Contains(name) == false) { _listnersData[name] = new ArrayList(); } ArrayList listnerList = (ArrayList)_listnersData[name]; if (!listnerList.Contains(observer)) { listnerList.Add(observer); } }