示例#1
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection props  = TypeDescriptor.GetProperties(value, attributes);
            List <PropertyDescriptor>    result = new List <PropertyDescriptor>(props.Count);

            foreach (PropertyDescriptor prop in props)
            {
                PropertyDescriptor addProperty = prop;

                if (ExcludedProperties.Contains(prop.Name))
                {
                    continue;
                }

                if (PropertyAttributes.ContainsKey(prop.PropertyType))
                {
                    List <Attribute> attributeList = new List <Attribute>(prop.Attributes.OfType <Attribute>());
                    attributeList.AddRange(PropertyAttributes[prop.PropertyType]);

                    addProperty = new PropertyGridPropertyDescriptor(prop, attributeList.ToArray());
                }

                result.Add(addProperty);
            }

            return(new PropertyDescriptorCollection(result.ToArray()));
        }
示例#2
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection props = TypeDescriptor.GetProperties(value, attributes);
            List<PropertyDescriptor> result = new List<PropertyDescriptor>(props.Count);

            foreach (PropertyDescriptor prop in props)
            {
                PropertyDescriptor addProperty = prop;

                if (ExcludedProperties.Contains(prop.Name))
                {
                    continue;
                }

                if (PropertyAttributes.ContainsKey(prop.PropertyType))
                {
                    List<Attribute> attributeList = new List<Attribute>(prop.Attributes.OfType<Attribute>());
                    attributeList.AddRange(PropertyAttributes[prop.PropertyType]);

                    addProperty = new PropertyGridPropertyDescriptor(prop, attributeList.ToArray());
                }

                result.Add(addProperty);
            }

            return new PropertyDescriptorCollection(result.ToArray());
        }