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); }
public void PropertyNameCustomization() { PropertyDescriptor property = Thing.GetField1Property(); Assert.AreEqual("Field1", property.Name); IPropertyCustomization customization = (IPropertyCustomization)property; customization.SetName("FIELD1"); Assert.AreEqual("FIELD1", property.Name); }
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); }
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); }
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)); }
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); }