コード例 #1
0
        public void TestCreateAction1b()
        {
            string  n   = nameof(ExampleClass2.Increment);
            Action1 inc = Accelerator.CreateAction1(typeof(ExampleClass2).GetMethod(n, Type.EmptyTypes));

            var o = new ExampleClass2();

            o.Increment();
            Assert.AreEqual(1, o.Value);
            inc(o);
            Assert.AreEqual(2, o.Value);
            inc(o);
            inc(o);
            Assert.AreEqual(4, o.Value);
        }
コード例 #2
0
        public void TestCreateAction1d()
        {
            string  n   = nameof(ExampleStruct2.Increment);
            Action1 inc = Accelerator.CreateAction1(typeof(ExampleStruct2).GetMethod(n, Type.EmptyTypes));

            var unboxed = new ExampleStruct2();

            unboxed.Increment();
            Assert.AreEqual(1, unboxed.Value);

            IExample boxed = unboxed;

            inc(boxed);
            Assert.AreEqual(2, boxed.Value);
            inc(boxed);
            inc(boxed);
            Assert.AreEqual(4, boxed.Value);
        }