Exemplo n.º 1
0
        public void ValueTypePropertyGetterAsString(string propertyName, object expected)
        {
            FormattablePropertyGetter <TestStruct> getString = DynamicType <TestStruct> .CreateFormattablePropertyGetter(propertyName);

            TestStruct testStruct = TestStruct.Default;

            Assert.AreEqual(expected, getString(testStruct, null));
        }
Exemplo n.º 2
0
        public void ReferenceTypePropertyGetterAsString(string propertyName, object expected)
        {
            FormattablePropertyGetter <TestClass> getString = DynamicType <TestClass> .CreateFormattablePropertyGetter(propertyName);

            TestClass obj = new TestClass();

            Assert.AreEqual(expected, getString(obj, null));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 public Introspector(FormattablePropertyGetter <T> getter, MemberInfo propertyInfo, string format)
 {
     Getter = getter;
     Name   = propertyInfo.Name;
     DiffVisibleAttribute = (DiffVisibleAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(DiffVisibleAttribute));
     if (format != null)
     {
         Format = format;
     }
     else if (DiffVisibleAttribute != null)
     {
         Format = DiffVisibleAttribute.Format;
     }
 }
Exemplo n.º 7
0
 public Introspector(FormattablePropertyGetter <T> getter, MemberInfo propertyInfo) : this(getter, propertyInfo, null)
 {
 }