Esempio n. 1
0
        private void GetChildProperties()
        {
            if (Value == null)
            {
                return;
            }

            var propertyItems = new List <PropertyItem>();

            try
            {
                PropertyDescriptorCollection descriptors = PropertyGridUtilities.GetPropertyDescriptors(Value);

                foreach (PropertyDescriptor descriptor in descriptors)
                {
                    if (descriptor.IsBrowsable)
                    {
                        propertyItems.Add(PropertyGridUtilities.CreatePropertyItem(descriptor, Instance, PropertyGrid, String.Format("{0}.{1}", BindingPath, descriptor.Name), Level + 1));
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO: handle this some how
            }

            Properties = PropertyGridUtilities.GetAlphabetizedProperties(propertyItems);
        }
Esempio n. 2
0
        private List <PropertyItem> GetObjectProperties(object instance)
        {
            var propertyItems = new List <PropertyItem>();

            if (instance == null)
            {
                return(propertyItems);
            }

            try
            {
                PropertyDescriptorCollection descriptors = PropertyGridUtilities.GetPropertyDescriptors(instance);

                if (!AutoGenerateProperties)
                {
                    List <PropertyDescriptor> specificProperties = new List <PropertyDescriptor>();
                    foreach (PropertyDefinition pd in PropertyDefinitions)
                    {
                        foreach (PropertyDescriptor descriptor in descriptors)
                        {
                            if (descriptor.Name == pd.Name)
                            {
                                specificProperties.Add(descriptor);
                                break;
                            }
                        }
                    }

                    descriptors = new PropertyDescriptorCollection(specificProperties.ToArray());
                }

                foreach (PropertyDescriptor descriptor in descriptors)
                {
                    if (descriptor.IsBrowsable)
                    {
                        propertyItems.Add(PropertyGridUtilities.CreatePropertyItem(descriptor, instance, this, descriptor.Name));
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO: handle this some how
            }

            return(propertyItems);
        }