Esempio n. 1
0
        static void Main(string[] args)
        {
            var jsEngineSwitcher = JsEngineSwitcher.Current;

            jsEngineSwitcher.EngineFactories.Add(new ChakraCoreJsEngineFactory());
            jsEngineSwitcher.DefaultEngineName = ChakraCoreJsEngine.EngineName;

            ServiceRow b = new ServiceRow();

            b.Add("test", "test1");

            ServiceRow a = new ServiceRow(b);

            a.Add("c1", "c2");
            b.Add("arr", new List <ServiceRow>()
            {
                a
            });

            IJsEngine jsEngine = JsEngineSwitcher.Current.CreateDefaultEngine();

            jsEngine.EmbedHostType("ServiceRow", typeof(ServiceRow));
            jsEngine.EmbedHostObject("root", a);
            jsEngine.Execute(@" var a = root.GetParent(); var t= a.GetListItem('arr',0); a.SetItem('test',t.GetItem('c1'));");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var engineSwitcher = JsEngineSwitcher.Current;

            engineSwitcher.EngineFactories.Add(new ChakraCoreJsEngineFactory());
            engineSwitcher.DefaultEngineName = ChakraCoreJsEngine.EngineName;
            IJsEngine engine = JsEngineSwitcher.Current.CreateDefaultEngine();

            engine.EmbedHostType("Test", typeof(Test));
            var t = new Test();

            engine.EmbedHostObject("TestA", t);
            engine.Execute("var a=1+3;if(1)a=5;TestA.Name=a");
            Console.WriteLine(t.Name);
            Console.ReadKey();
        }
Esempio n. 3
0
 public void EmbedHostType(string itemName, Type type)
 {
     CheckDisposed();
     _engine.EmbedHostType(itemName, type);
 }