Пример #1
0
 public void CtorFieldInfo()
 {
     var fieldInfo = typeof(ComplexType).GetField(nameof(ComplexType.value));
     var getterAndSetter = new GetterAndSetter<ComplexType, int>(fieldInfo);
     var complexType = new ComplexType();
     getterAndSetter.SetValue(complexType, 1);
     Assert.AreEqual(1, complexType.Value);
     Assert.AreEqual(1, getterAndSetter.GetValue(complexType));
 }
Пример #2
0
        public void CtorFieldInfo()
        {
            var fieldInfo       = typeof(ComplexType).GetField(nameof(ComplexType.value));
            var getterAndSetter = new GetterAndSetter <ComplexType, int>(fieldInfo);
            var complexType     = new ComplexType();

            getterAndSetter.SetValue(complexType, 1);
            Assert.AreEqual(1, complexType.Value);
            Assert.AreEqual(1, getterAndSetter.GetValue(complexType));
        }
Пример #3
0
        public void CtorFieldInfo()
        {
            var type = typeof(ComplexType);

            foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
            {
                var getterAndSetter = new GetterAndSetter <ComplexType, int>(field);
                var complexType     = new ComplexType();
                getterAndSetter.SetValue(complexType, 1);
                Assert.AreEqual(1, complexType.Value);
                Assert.AreEqual(1, getterAndSetter.GetValue(complexType));
            }
        }