示例#1
0
        public void FieldGetMethodDelegateCacheTest()
        {
            PropertyTestObject data = PropertyTestObject.PrepareTestData();

            Func <object, object> reader1 = (Func <object, object>)DynamicHelper.GetFiledGetterDelegate(typeof(PropertyTestObject).GetField("PublicField"), typeof(object));
            Func <object, object> reader2 = (Func <object, object>)DynamicHelper.GetFiledGetterDelegate(typeof(PropertyTestObject).GetField("PublicField"), typeof(object));

            Assert.AreSame(reader1, reader2);
        }
示例#2
0
        public void SimpleFieldGetTest()
        {
            PropertyTestObject data = PropertyTestObject.PrepareTestData();

            string originalValue = data.PublicField;

            Func <object, string> reader = (Func <object, string>)DynamicHelper.GetFiledGetterDelegate(typeof(PropertyTestObject).GetField("PublicField"));

            string idRead = reader(data);

            Assert.AreEqual(originalValue, idRead);
        }