public static void SetObject(this JSContext ctx, String Namespace, String Name, NSObject Data) { //split the namespace into sections var names = Namespace.Split('.'); if (names.Length == 0) { return; } var aRoot = ctx.GetOrCreate(names [0]); if (names.Length == 1) { aRoot.SetObject(Data, Name); } JSValue endPoint = null; for (int loop = 1; loop < names.Length; loop++) { endPoint = aRoot.GetOrCreate(names [loop]); } if (endPoint != null && !endPoint.IsUndefined) { endPoint.SetObject(Data, Name); } }
/// <summary> /// Attach the specified context. /// </summary> /// <param name="ctx">Context.</param> public static void Attach(JSContext ctx) { //build an namespace structure for the class var aClass = ctx.GetOrCreate(@"DSoft"); var aMobile = aClass.GetOrCreate(@"Online"); aMobile.SetObject(new DSHybridHandler(), @"Native"); aMobile.SetObject(new DSHybridHandler(), @"Cheese"); }
/// <summary> /// Attach the specified context. /// </summary> /// <param name="ctx">Context.</param> public static void Attach (JSContext ctx) { //build an namespace structure for the class var aClass = ctx.GetOrCreate (@"DSoft"); var aMobile = aClass.GetOrCreate (@"Online"); aMobile.SetObject (new DSHybridHandler (), @"Native"); aMobile.SetObject (new DSHybridHandler (), @"Cheese"); }