public static void HandleContent(NSObject content, IContentsListener listener) { if (content.GetType() == typeof(NITContent)) { NITContent cont = (NITContent)content; listener.GotContentNotification(cont); } else if (content.GetType() == typeof(NITSimpleNotification)) { NITSimpleNotification cont = (NITSimpleNotification)content; listener.GotSimpleNotification(cont); } else if (content.GetType() == typeof(NITCoupon)) { NITCoupon cont = (NITCoupon)content; listener.GotCouponNotification(cont); } else if (content.GetType() == typeof(NITCustomJSON)) { NITCustomJSON cont = (NITCustomJSON)content; listener.GotCustomJSONNotification(cont); } else if (content.GetType() == typeof(NITFeedback)) { NITFeedback cont = (NITFeedback)content; listener.GotFeedbackNotification(cont); } }
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 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"); } }