Пример #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));
        }
Пример #2
0
        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));
        }
Пример #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));
        }
Пример #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);
            }
        }
Пример #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);
            }
        }