public void FromCustomJsonNativeToCommon() { NSMutableDictionary <NSString, NSObject> nativeDic = new NSMutableDictionary <NSString, NSObject>(); nativeDic.Add(new NSString("nome"), new NSString("stefano")); nativeDic.Add(new NSString("numero"), new NSNumber(4.6)); NSNumber number3 = new NSNumber(3.0); NSNumber number4 = new NSNumber(4.0); NSArray array = NSArray.FromObjects(number3, number4); nativeDic.Add(new NSString("lista"), array); NSMutableDictionary <NSString, NSObject> innerNativeDic = new NSMutableDictionary <NSString, NSObject>(); innerNativeDic.Add(new NSString("nome"), new NSString("martin")); innerNativeDic.Add(new NSString("cognome"), new NSString("scorsese")); NSDictionary <NSString, NSObject> innerDic = new NSDictionary <NSString, NSObject>(innerNativeDic.Keys, innerNativeDic.Values); nativeDic.Add(new NSString("inner_object"), innerDic); NSDictionary <NSString, NSObject> dic = new NSDictionary <NSString, NSObject>(nativeDic.Keys, nativeDic.Values); NITCustomJSON nativeCUstomJson = new NITCustomJSON(); nativeCUstomJson.Content = dic; nativeCUstomJson.NotificationMessage = "messaggio"; XCCustomJSONNotification jSONNotification = AdapterCustom.GetCommonType(nativeCUstomJson); Assert.True(jSONNotification.Content is Dictionary <string, object>); jSONNotification.Content.TryGetValue("nome", out object stringValue); Assert.True(stringValue is string); Assert.True(stringValue.Equals("stefano")); jSONNotification.Content.TryGetValue("numero", out object doubleValue); Assert.True(doubleValue is double); Assert.True(doubleValue.Equals(4.6)); jSONNotification.Content.TryGetValue("lista", out object listValue); Assert.True(listValue is List <object>); Assert.True((listValue as List <object>)[0] is double); Assert.True((double)(listValue as List <object>)[0] == 3.0); Assert.True((listValue as List <object>)[1] is double); Assert.True((double)(listValue as List <object>)[1] == 4.0); jSONNotification.Content.TryGetValue("inner_object", out object innerObj); Assert.True(innerObj is Dictionary <string, object>); Dictionary <string, object> castedDic = innerObj as Dictionary <string, object>; castedDic.TryGetValue("nome", out object name); Assert.True(name is string); Assert.True(((string)name).Equals("martin")); castedDic.TryGetValue("cognome", out object cognome); Assert.True(cognome is string); Assert.True(((string)cognome).Equals("scorsese")); }
public static XCCustomJSONNotification GetCommonType(NITCustomJSON CustomJSONNotification) { XCCustomJSONNotification XCustomJSON = new XCCustomJSONNotification(); XCustomJSON.NotificationMessage = CustomJSONNotification.NotificationMessage; XCustomJSON.Id = CustomJSONNotification.ID; XCustomJSON.Content = From(CustomJSONNotification.Content); return(XCustomJSON); }
public static XCCustomJSONNotification GetCommonType(CustomJSON CustomJSONNotification) { XCCustomJSONNotification XCustomJSON = new XCCustomJSONNotification(); XCustomJSON.NotificationMessage = CustomJSONNotification.NotificationMessage; XCustomJSON.Content = From((Android.Runtime.JavaDictionary)CustomJSONNotification.Content); XCustomJSON.Id = CustomJSONNotification.Id; return(XCustomJSON); }
public override void GotCustomJSON(NITCustomJSON CustomJSON, NITTrackingInfo TrackingInfo) { XCCustomJSONNotification XCustomJSON = AdapterCustom.GetCommonType(CustomJSON); if (NearPCL.GetContentManager() != null) { NearPCL.GetContentManager().GotXCustomJSONNotification(XCustomJSON); } else { Console.WriteLine("You receive a content but you haven't registered a content manager"); } }
public void FromNativeToBridgeCustomJSON() { CustomJSON customJSON = new CustomJSON(); JavaDictionary jsonMap = new JavaDictionary(); jsonMap.Add("nome", "stefano"); jsonMap.Add("numero", 4.6); Java.Util.ArrayList lista = new Java.Util.ArrayList(); lista.Add(3.0); lista.Add(4.0); jsonMap.Add("lista", lista); JavaDictionary innerDict = new JavaDictionary(); innerDict.Add("nome", "martin"); innerDict.Add("cognome", "scorsese"); jsonMap.Add("inner_object", innerDict); customJSON.Content = jsonMap; customJSON.NotificationMessage = "messaggio"; XCCustomJSONNotification jSONNotification = AdapterCustom.GetCommonType(customJSON); Assert.True(jSONNotification.Content is Dictionary <string, object>); jSONNotification.Content.TryGetValue("nome", out object stringValue); Assert.True(stringValue is string); Assert.True(stringValue.Equals("stefano")); jSONNotification.Content.TryGetValue("numero", out object doubleValue); Assert.True(doubleValue is double); Assert.True(doubleValue.Equals(4.6)); jSONNotification.Content.TryGetValue("lista", out object listValue); Assert.True(listValue is List <object>); Assert.True((listValue as List <object>)[0] is double); Assert.True((double)(listValue as List <object>)[0] == 3.0); Assert.True((listValue as List <object>)[1] is double); Assert.True((double)(listValue as List <object>)[1] == 4.0); jSONNotification.Content.TryGetValue("inner_object", out object innerObj); Assert.True(innerObj is Dictionary <string, object>); Dictionary <string, object> castedDic = innerObj as Dictionary <string, object>; castedDic.TryGetValue("nome", out object name); Assert.True(name is string); Assert.True(((string)name).Equals("martin")); castedDic.TryGetValue("cognome", out object cognome); Assert.True(cognome is string); Assert.True(((string)cognome).Equals("scorsese")); }
public void GotXCustomJSONNotification(XCCustomJSONNotification notification) { throw new NotImplementedException(); }