public static NSType GetNSRR() { var server = ServerTest.GetServer(); var zone = ZoneTest.GetZone(); var record = zone.GetRecords().FirstOrDefault(i => i.OwnerName == "ns." + zone.Name); if (record == null) { record = NSType.CreateInstanceFromPropertyData(server, server.Name, zone.Name, "ns." + zone.Name, DNSManagement.RR.ResourceRecord.RecordClassEnum.IN, null, "nshost1"); } return((NSType)record.UnderlyingRecord); }
/* * dictionary is first parameter, because the compiler must be able to see a difference between * SendEventWithArgs(Dictionary<string,object> args,string name) * and * public static void SendEventsWithArgs(string name, params object[] args) * the elements in the ArrayList and values in the Dictionary must have one of these types: * string, int, long, float, double, null, ArrayList, Dictionary<String,object> */ public static void Event(Dictionary <string, object> args, string name) { Debug.Log(string.Format("SingularSDK Event: args JSON={0}", JsonConvert.SerializeObject(args, Formatting.None))); if (!Initialized) { return; } if (!Application.isEditor) { #if UNITY_IOS Init_NSDictionary(); Init_NSMasterArray(); Dictionary <string, object> .Enumerator enumerator = args.GetEnumerator(); while (enumerator.MoveNext()) { NSType type = NSType.STRING; if (enumerator.Current.Value == null) { type = NSType.NULL; Push_NSDictionary(enumerator.Current.Key, "", (int)type); } else { System.Type valueType = enumerator.Current.Value.GetType(); if (valueType == typeof(int)) { type = NSType.INT; } else if (valueType == typeof(long)) { type = NSType.LONG; } else if (valueType == typeof(float)) { type = NSType.FLOAT; } else if (valueType == typeof(double)) { type = NSType.DOUBLE; } else if (valueType == typeof(Dictionary <string, object>)) { type = NSType.DICTIONARY; CreateDictionary(-1, NSType.DICTIONARY, enumerator.Current.Key, (Dictionary <string, object>)enumerator.Current.Value); } else if (valueType == typeof(ArrayList)) { type = NSType.ARRAY; CreateArray(-1, NSType.DICTIONARY, enumerator.Current.Key, (ArrayList)enumerator.Current.Value); } if ((int)type < (int)NSType.ARRAY) { Push_NSDictionary(enumerator.Current.Key, enumerator.Current.Value.ToString(), (int)type); } } } SendEventWithArgs(name); Free_NSDictionary(); Free_NSMasterArray(); #elif UNITY_ANDROID AndroidJavaObject json = new AndroidJavaObject("org.json.JSONObject", JsonConvert.SerializeObject(args, Formatting.None)); if (singular != null) { status = singular.CallStatic <bool>("eventJSON", name, json); } #endif } }
public static bool StartSingularSessionWithLaunchOptions(string key, string secret, Dictionary <string, object> options) { if (!Application.isEditor) { #if UNITY_IOS Init_NSDictionary(); Init_NSMasterArray(); Dictionary <string, object> .Enumerator enumerator = options.GetEnumerator(); while (enumerator.MoveNext()) { NSType type = NSType.STRING; if (enumerator.Current.Value == null) { type = NSType.NULL; Push_NSDictionary(enumerator.Current.Key, "", (int)type); } else { System.Type valueType = enumerator.Current.Value.GetType(); if (valueType == typeof(int)) { type = NSType.INT; } else if (valueType == typeof(long)) { type = NSType.LONG; } else if (valueType == typeof(float)) { type = NSType.FLOAT; } else if (valueType == typeof(double)) { type = NSType.DOUBLE; } else if (valueType == typeof(Dictionary <string, object>)) { type = NSType.DICTIONARY; CreateDictionary(-1, NSType.DICTIONARY, enumerator.Current.Key, (Dictionary <string, object>)enumerator.Current.Value); } else if (valueType == typeof(ArrayList)) { type = NSType.ARRAY; CreateArray(-1, NSType.DICTIONARY, enumerator.Current.Key, (ArrayList)enumerator.Current.Value); } if ((int)type < (int)NSType.ARRAY) { Push_NSDictionary(enumerator.Current.Key, enumerator.Current.Value.ToString(), (int)type); } } } StartSingularSessionWithLaunchOptions_(key, secret); Free_NSDictionary(); Free_NSMasterArray(); return(true); #endif } return(false); }
private static void CreateArray(int parent, NSType parentType, string key, ArrayList source) { int arrayIndex = New_NSArray(); foreach (object o in source) { //test if string,int,float,double,null; NSType type = NSType.STRING; if (o == null) { type = NSType.NULL; Push_To_Child_Array("", (int)type, arrayIndex); } else { System.Type valueType = o.GetType(); if (valueType == typeof(int)) { type = NSType.INT; } else if (valueType == typeof(long)) { type = NSType.LONG; } else if (valueType == typeof(float)) { type = NSType.FLOAT; } else if (valueType == typeof(double)) { type = NSType.DOUBLE; } else if (valueType == typeof(Dictionary <string, object>)) { type = NSType.DICTIONARY; CreateDictionary(arrayIndex, NSType.ARRAY, "", (Dictionary <string, object>)o); } else if (valueType == typeof(ArrayList)) { type = NSType.ARRAY; CreateArray(arrayIndex, NSType.ARRAY, "", (ArrayList)o); } if ((int)type < (int)NSType.ARRAY) { Push_To_Child_Array(o.ToString(), (int)type, arrayIndex); } } } if (parent < 0) { Push_Container_NSDictionary(key, arrayIndex); } else { if (parentType == NSType.ARRAY) { Push_Container_To_Child_Array(parent, arrayIndex); } else { Push_Container_To_Child_Dictionary(key, parent, arrayIndex); } } }
private static void CreateDictionary(int parent, NSType parentType, string key, Dictionary <string, object> source) { int dictionaryIndex = New_NSDictionary(); Dictionary <string, object> .Enumerator enumerator = source.GetEnumerator(); while (enumerator.MoveNext()) { //test if string,int,float,double,null; NSType type = NSType.STRING; if (enumerator.Current.Value == null) { type = NSType.NULL; Push_To_Child_Dictionary(enumerator.Current.Key, "", (int)type, dictionaryIndex); } else { System.Type valueType = enumerator.Current.Value.GetType(); if (valueType == typeof(int)) { type = NSType.INT; } else if (valueType == typeof(long)) { type = NSType.LONG; } else if (valueType == typeof(float)) { type = NSType.FLOAT; } else if (valueType == typeof(double)) { type = NSType.DOUBLE; } else if (valueType == typeof(Dictionary <string, object>)) { type = NSType.DICTIONARY; CreateDictionary(dictionaryIndex, NSType.DICTIONARY, enumerator.Current.Key, (Dictionary <string, object>)enumerator.Current.Value); } else if (valueType == typeof(ArrayList)) { type = NSType.ARRAY; CreateArray(dictionaryIndex, NSType.DICTIONARY, enumerator.Current.Key, (ArrayList)enumerator.Current.Value); } if ((int)type < (int)NSType.ARRAY) { Push_To_Child_Dictionary(enumerator.Current.Key, enumerator.Current.Value.ToString(), (int)type, dictionaryIndex); } } } if (parent < 0) { Push_Container_NSDictionary(key, dictionaryIndex); } else { if (parentType == NSType.ARRAY) { Push_Container_To_Child_Array(parent, dictionaryIndex); } else { Push_Container_To_Child_Dictionary(key, parent, dictionaryIndex); } } }