コード例 #1
0
        public static void Run()
        {
            DynamicMethod dm = Util.Compile("if (b >= 10) return; a=1;b=b+a;", typeof(TestPersist));

            TestPersist obj = new TestPersist();

            DMCall d = (DMCall)dm.CreateDelegate(typeof(DMCall), obj);

            for (int i = 0; i < 15; i++)
            {
                d();
                Console.WriteLine(obj.State.GetValue <float>("b"));
            }

            dm = Util.Compile("print(x);x=2;nullobj.ToString();", typeof(TestPersist));

            d = (DMCall)dm.CreateDelegate(typeof(DMCall), obj);

            try {
                d();
            } catch {
            }

            try {
                d();
            } catch {
            }
        }
コード例 #2
0
        public static void Run()
        {
            DynamicMethod dm = Util.Compile("if (b >= 10) return; a=1;b=b+a;", typeof(TestPersist));

            TestPersist obj = new TestPersist();

            DMCall d = (DMCall) dm.CreateDelegate(typeof(DMCall), obj);

            for (int i = 0; i < 15; i++) {
                d();
                Console.WriteLine(obj.State.GetValue<float>("b"));
            }

            dm = Util.Compile("print(x);x=2;nullobj.ToString();", typeof(TestPersist));

            d = (DMCall) dm.CreateDelegate(typeof(DMCall), obj);

            try {
                d();
            } catch {
            }

            try {
                d();
            } catch {
            }
        }