Пример #1
0
        private static void SetName(PropertyDescriptor property, string name)
        {
            Debug.Assert(property != null);
            Debug.Assert(name != null);
            Debug.Assert(name.Length > 0);

            IPropertyCustomization customization = (IPropertyCustomization)property;

            customization.SetName(name);
        }
Пример #2
0
        public void PropertyNameCustomization()
        {
            PropertyDescriptor property = Thing.GetField1Property();

            Assert.AreEqual("Field1", property.Name);
            IPropertyCustomization customization = (IPropertyCustomization)property;

            customization.SetName("FIELD1");
            Assert.AreEqual("FIELD1", property.Name);
        }
Пример #3
0
        public void PropertyTypeCustomization()
        {
            PropertyDescriptor property = Thing.GetField1Property();

            Assert.AreEqual(typeof(object), property.PropertyType);
            IPropertyCustomization customization = (IPropertyCustomization)property;

            customization.SetType(typeof(string));
            Assert.AreEqual(typeof(string), property.PropertyType);
        }
Пример #4
0
        public void PropertySetterCustomization()
        {
            Thing thing = new Thing();
            PropertyDescriptor property = Thing.GetField1Property();

            Assert.IsNull(thing.Field1);
            IPropertyCustomization customization = (IPropertyCustomization)property;
            FakePropertyImpl       impl          = new FakePropertyImpl();

            impl.BaseImpl = customization.OverrideImpl(impl);
            property.SetValue(thing, "test");
            Assert.AreEqual(">>test", thing.Field1);
        }
Пример #5
0
        public void PropertyGetterCustomization()
        {
            Thing thing = new Thing();
            PropertyDescriptor property  = Thing.GetField1Property();
            const string       testValue = "test";

            thing.Field1 = testValue;
            Assert.AreEqual(testValue, thing.Field1);
            IPropertyCustomization customization = (IPropertyCustomization)property;
            FakePropertyImpl       impl          = new FakePropertyImpl();

            impl.BaseImpl = customization.OverrideImpl(impl);
            Assert.IsNotNull(impl.BaseImpl);
            Assert.AreEqual("<<" + testValue, property.GetValue(thing));
        }
Пример #6
0
        protected virtual void ApplyCustomization(PropertyDescriptor property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            if (Name.Length == 0)
            {
                return;
            }

            IPropertyCustomization customization = (IPropertyCustomization)property;

            customization.SetName(Name);
        }