public void ValueTypePropertyGetterAsString(string propertyName, object expected) { FormattablePropertyGetter <TestStruct> getString = DynamicType <TestStruct> .CreateFormattablePropertyGetter(propertyName); TestStruct testStruct = TestStruct.Default; Assert.AreEqual(expected, getString(testStruct, null)); }
public void ReferenceTypePropertyGetterAsFormattedString(string propertyName, string format, object expected) { FormattablePropertyGetter <TestClass> getString = DynamicType <TestClass> .CreateFormattablePropertyGetter(propertyName); TestClass obj = new TestClass(); Assert.AreEqual(expected, getString(obj, format)); }
public void PhoneNumberGetterAsString(long phoneNumber, string propertyName, string expectedValue) { FormattablePropertyGetter <PhoneNumber> getString = DynamicType <PhoneNumber> .CreateFormattablePropertyGetter(propertyName); PhoneNumber number = phoneNumber; Assert.AreEqual(expectedValue, getString(number, null)); }
private void InitializeIntrospection(IEnumerable <FormattedProperty> formattedProperties) { foreach (FormattedProperty formattedProperty in formattedProperties) { FormattablePropertyGetter <T> getter = DynamicType <T> .CreateFormattablePropertyGetter(formattedProperty.PropertyName); PropertyInfo propertyInfo = typeof(T).GetProperty(formattedProperty.PropertyName); Introspector introspector = new Introspector(getter, propertyInfo, formattedProperty.Format); introspectors.Add(introspector); } }
private void InitializeIntrospection(IList <string> properties) { for (int i = 0; i < properties.Count; i++) { string property = properties[i]; FormattablePropertyGetter <T> getter = DynamicType <T> .CreateFormattablePropertyGetter(property); PropertyInfo propertyInfo = typeof(T).GetProperty(property); Introspector introspector = new Introspector(getter, propertyInfo); introspectors.Add(introspector); } }