예제 #1
0
 private static void AddDefaultGetter(PropertyDescriptor descriptor)
 {
     if (descriptor.TypeConverter != null)
     {
         descriptor.AddBehavior(new DefaultPropertyGetter(descriptor.TypeConverter));
     }
 }
예제 #2
0
        /// <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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }