private static void AddDefaultGetter(PropertyDescriptor descriptor) { if (descriptor.TypeConverter != null) { descriptor.AddBehavior(new DefaultPropertyGetter(descriptor.TypeConverter)); } }
/// <summary> /// Copies the behaviors to the other <see cref="PropertyDescriptor"/> /// </summary> /// <param name="other"></param> /// <returns></returns> public PropertyDescriptor CopyBehaviors(PropertyDescriptor other) { var behaviors = dictionaryBehaviors; if (behaviors != null) { var count = behaviors.Count; for (var i = 0; i < count; i++) { var behavior = behaviors[i].Copy(); if (behavior != null) { other.AddBehavior(behavior); } } } return(this); }
private static IDictionary <string, PropertyDescriptor> MergeProperties( IDictionary <string, PropertyDescriptor> source, List <IDictionaryBehavior> behaviors) { int index, count = behaviors.Count; var properties = new Dictionary <string, PropertyDescriptor>(); foreach (var sourceProperty in source) { var property = new PropertyDescriptor(sourceProperty.Value, true); for (index = 0; index < count; index++) { property.AddBehavior(behaviors[index]); } properties[sourceProperty.Key] = property; } return(properties); }
object IDictionaryPropertyGetter.GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key, object storedValue, PropertyDescriptor property, bool ifExists) { if (storedValue == null) { var component = dictionaryAdapter.This.ExtendedProperties[property.PropertyName]; if (component == null) { var descriptor = new PropertyDescriptor(property.Property, null); descriptor.AddBehavior(new KeyPrefixAttribute(key)); component = dictionaryAdapter.This.Factory.GetAdapter( property.Property.PropertyType, dictionaryAdapter.This.Dictionary, descriptor); dictionaryAdapter.This.ExtendedProperties[property.PropertyName] = component; } return(component); } return(storedValue); }