コード例 #1
0
        public void AddBasicObject()
        {
            BasicMathObject bmo = new BasicMathObject()
            {
                ExpectedA = 1,
                ExpectedB = 5
            };

            scriptEngine.AddObject("Math", bmo);

            scriptEngine.AddCode("Math.Add 1, 5");

            scriptEngine.Start();
        }
コード例 #2
0
        public void AddBasicGlobalMemberObject()
        {
            BasicMathObject bmo = new BasicMathObject()
            {
                ExpectedA = 2,
                ExpectedB = 7
            };

            scriptEngine.AddGlobalMemberObject("Math", bmo);
            scriptEngine.Start();

            // No Math alias used.
            scriptEngine.AddCode("Add 2, 7");

            dynamic script = scriptEngine.GetScriptHandle();
        }
コード例 #3
0
        public void CallObjectWithNoAlias()
        {
            BasicMathObject bmo = new BasicMathObject()
            {
                ExpectedA = 1,
                ExpectedB = 5
            };

            scriptEngine.AddObject("Math", bmo);

            scriptEngine.AddCode("Add 1, 5");

            scriptEngine.Start();

            bmo.ExpectedA = 23;
            bmo.ExpectedB = 57;
        }
コード例 #4
0
        public void AddObjectsWithSameName()
        {
            BasicMathObject bmo = new BasicMathObject()
            {
                ExpectedA = 2,
                ExpectedB = 7
            };

            scriptEngine.AddObject("Math", bmo);

            try
            {
                scriptEngine.AddObject("Math", bmo);
                Assert.Fail("Expected ArgumentException");
            }
            catch (ArgumentException)
            {
            }
        }