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)); }
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)); }
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)); } }