Пример #1
0
        public void Initialize()
        {
            testFunctionsMock = new Mock <TestFunctions>();

            Context = new JSContext();
            Context.GetGlobalObject().SetProperty("simpleProperties", new SimpleProperties()
            {
                stringProperty = "stringPropertyValue",
                intProperty    = 3,
                floatProperty  = (float)Math.PI,
                doubleProperty = GOLDEN_RATIO,
                boolProperty   = true,
                floatsProperty = new float[] { 3.14f, 16 / 9 },
                dictProperty   = new Dictionary <object, object>()
                {
                    { "123", 2 },
                    { "string", "hello world" }
                },
                nonGenericDictionary = new Dictionary <string, object>()
                {
                    { "x", 1 }
                },
                nestedProperty = testFunctionsMock.Object
            });

            Context.GetGlobalObject().SetProperty("testFunctions", testFunctionsMock.Object);
        }
Пример #2
0
 private void CreateWindowScriptObject(JSContext context)
 {
     if (ObjectForScripting != null && context != null)
     {
         JSObject global = context.GetGlobalObject();
         JSObject window = global.GetProperty("window") as JSObject;
         if (window != null)
         {
             window.SetProperty("external", (object)ObjectForScripting);
         }
     }
 }
Пример #3
0
        public void Initialize()
        {
            testFunctionsMock = new Mock<TestFunctions>();

            Context = new JSContext();
            Context.GetGlobalObject().SetProperty("simpleProperties", new SimpleProperties()
            {
                stringProperty = "stringPropertyValue",
                intProperty = 3,
                floatProperty = (float)Math.PI,
                doubleProperty = GOLDEN_RATIO,
                boolProperty = true,
                floatsProperty = new float[] { 3.14f, 16/9 },
                dictProperty = new Dictionary<object,object>() {
                    {"123", 2},
                    {"string", "hello world"}
                },
                nonGenericDictionary = new Dictionary<string, object>() { { "x", 1 } },
                nestedProperty = testFunctionsMock.Object
            });

            Context.GetGlobalObject().SetProperty("testFunctions", testFunctionsMock.Object);
        }
Пример #4
0
 private void CreateWindowScriptObject(JSContext context)
 {
     if (ObjectForScripting != null && context != null)
     {
         JSObject global = context.GetGlobalObject();
         JSValue  window = global.GetProperty("window");
         if (window == null || !window.IsObject)
         {
             return;
         }
         JSObject windowObj = window.ToObject();
         if (windowObj == null)
         {
             return;
         }
         windowObj.SetProperty("external", (object)ObjectForScripting);
     }
 }
Пример #5
0
 private void CreateWindowScriptObject(JSContext context)
 {
     if (ObjectForScripting != null && context != null)
     {
         JSObject global = context.GetGlobalObject();
         JSObject window = global.GetProperty("window") as JSObject;
         if (window != null)
             window.SetProperty("external", (object)ObjectForScripting);
     }
 }
Пример #6
0
 public void FixtureSetup()
 {
     Context = new JSContext();
     Context.GetGlobalObject().SetProperty("tests", new TestGlobalObject());
 }
Пример #7
0
        private void CreateWindowScriptObject(JSContext context)
        {
            if (ObjectForScripting != null && context != null)
            {
                JSObject global = context.GetGlobalObject();
                JSValue window = global.GetProperty("window");
                if (window == null || !window.IsObject)
                {
                    return;
                }

                JSObject windowObj = window.ToObject();
                if (windowObj == null)
                {
                    return;
                }

                windowObj.SetProperty("external", ObjectForScripting);
            }
        }
Пример #8
0
 public void FixtureSetup()
 {
     Context = new JSContext();
     Context.GetGlobalObject().SetProperty("tests", new TestGlobalObject());
 }