internal DynamicProperty(PropertyGridUtils descriptor, Type type, object value, string name, Attribute[] attrs)
                : base(name, attrs)
            {
                this.descriptor = descriptor;
                this.type       = type;
                Value           = value;

                DefaultValueAttribute def = PropertyGridUtils.GetAttribute <DefaultValueAttribute>(Attributes);

                if (def == null)
                {
                    hasDefaultValue = false;
                }
                else
                {
                    hasDefaultValue = true;
                    defaultValue    = def.Value;
                }

                if (attrs != null)
                {
                    foreach (Attribute att in attrs)
                    {
                        attributes.Add(att);
                    }
                }
            }
        public PropertyGridUtils FromComponent(object component)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            if (!type.IsAssignableFrom(component.GetType()))
            {
                throw new ArgumentException(null, "component");
            }

            PropertyGridUtils desc = new PropertyGridUtils();

            desc.type      = type;
            desc.Component = component;

            // shallow copy on purpose
            desc.typeConverter      = typeConverter;
            desc.editors            = editors;
            desc.defaultEvent       = defaultEvent;
            desc.defaultProperty    = defaultProperty;
            desc.attributes         = attributes;
            desc.events             = events;
            desc.OriginalProperties = OriginalProperties;

            // track values
            List <PropertyDescriptor> properties = new List <PropertyDescriptor>();

            foreach (PropertyDescriptor pd in Properties)
            {
                DynamicProperty ap = new DynamicProperty(desc, pd, component);
                properties.Add(ap);
            }

            desc.Properties = new PropertyDescriptorCollection(properties.ToArray());
            return(desc);
        }
 internal DynamicProperty(PropertyGridUtils descriptor, PropertyDescriptor existing, object component)
     : this(descriptor, existing.PropertyType, existing.GetValue(component), existing.Name, GetAttributes(existing))
 {
     this.existing = existing;
 }