public void AddAttribute <TAttribute>(string propertyName, TAttribute attribute) where TAttribute : Attribute
        {
            var property = (DynamicPropertyDescriptor)GetProperties()[propertyName];

            properties.Remove(propertyName);
            var newPropertyWithAttribute = new DynamicPropertyDescriptor(property, new Attribute[] { attribute });

            properties.Add(propertyName, newPropertyWithAttribute);
        }
        public PropertyDescriptorCollection GetProperties()
        {
            var meta        = _dynamic.GetMetaObject(Expression.Constant(_dynamic));
            var memberNames = meta.GetDynamicMemberNames();

            var props = new PropertyDescriptorCollection(new PropertyDescriptor[] { });

            foreach (var memberName in memberNames)
            {
                if (!properties.ContainsKey(memberName))
                {
                    var newProperty = new DynamicPropertyDescriptor(_dynamic, memberName);
                    properties.Add(memberName, newProperty);
                }

                props.Add(properties[memberName]);
            }

            return(props);
        }
        public override bool Equals(object obj)
        {
            DynamicPropertyDescriptor other = obj as DynamicPropertyDescriptor;

            return(other != null && other._propertyName.Equals(_propertyName));
        }
 public DynamicPropertyDescriptor(DynamicPropertyDescriptor oldDynamicPropertyDescriptor, Attribute[] newAttrs) : base(oldDynamicPropertyDescriptor, newAttrs)
 {
     _propertyName = oldDynamicPropertyDescriptor.Name;
     _owner        = oldDynamicPropertyDescriptor._owner;
 }