コード例 #1
0
        public void ActionPointerConstruction()
        {

            object s = 123;
            object func = null;

            ValuePointer funcPointer = new ValuePointer(() => func, (o) => func = o, typeof(Action<object>), false);

            funcPointer.Setter(new Action<object>((val) => s = val));

            ((Action<object>)funcPointer.Getter())(12);

            Assert.AreEqual(12, s); //Check that the action correctly set 12
        }
コード例 #2
0
        public void FuncPointerConstruction()
        {

            object s = 123;
            object func = null;

            ValuePointer funcPointer = new ValuePointer(() => func, (o) => func = o, typeof(Func<object>), false);

            funcPointer.Setter(new Func<object> (() => s));

            object obj = ((Func<object>)funcPointer.Getter())();

            Assert.AreEqual(s, obj); //Check that we got the correct object
        }