// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); LoadApplication(new App()); using (var j = new JSContext(true)) { j["a"] = j.CreateString("Akash"); j["k"] = j.CreateString("Kava"); var ak = j.Evaluate("`${a} ${k}`"); // Assert.Equal("Akash Kava", ak.ToString()); j["n5"] = j.CreateNumber(5); var a = j.Evaluate("4 + n5"); // Assert.True(a.IsNumber); // Assert.Equal(a.IntValue, 9); j["add"] = j.CreateFunction(0, (c, a1) => { return(j.CreateString($"{a1[0]} {a1[1]}")); }, "Add"); a = j.Evaluate("add(a, k)"); // Assert.Equal("Akash Kava", a.ToString()); } return(base.FinishedLaunching(app, options)); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); // var sys = new AndroidSystem(); // sys.Activity = this; // jc = new JSContext(true); // jc["system"] = jc.Serialize(sys, SerializationMode.WeakReference); //jc["log"] = jc.CreateFunction(0, (c, a) => { // System.Diagnostics.Debug.WriteLine(a[0]); // return c.Undefined; //}, "systemLogger"); // jc.Evaluate("console.log('hey')"); // jc.Evaluate("setTimeout(function() { log('This is long text message'); },100);"); // jc.Evaluate(@"new Promise(function(r,e) {})"); using (var j = new JSContext(true)) { j["Empty"] = j.CreateString(""); // j["Null"] = j.CreateString(null); j["a"] = j.CreateString("Akash"); j["k"] = j.CreateString("Kava"); var ak = j.Evaluate("`${a} ${k}`"); Assert.Equal("Akash Kava", ak.ToString()); j["n5"] = j.CreateNumber(5); var a = j.Evaluate("4 + n5"); Assert.True(a.IsNumber); Assert.Equal(a.IntValue, 9); j["add"] = j.CreateFunction(0, (c, a) => { return(j.CreateString($"{a[0]} {a[1]}")); }, "Add"); a = j.Evaluate("add(a, k)"); Assert.Equal("Akash Kava", a.ToString()); } this.RunOnUiThread(async() => { await BaseTest.RunAll(); }); }