Example #1
0
        public virtual PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            if (_properties == null)
            {
                _properties = new PropertyDescriptorCollection(null);

                // get list of properties through reflection
                PropertyWindowViewModelHelper.AddReflectedProperties(_properties, this, attributes, _editingContext);

                // add properties from extender objects
                PropertyWindowViewModelHelper.AddExtendedProperties(this, _properties, attributes, _editingContext);
            }

            return(PropertyWindowViewModelHelper.GetBrowsableProperties(_properties));
        }
Example #2
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes)
        {
            if (_lastComponent != component)
            {
                // one single instance of the type converter may be used for querying the
                // properties of different component instances, but the list of properties is
                // specific to each component, so invalidate the cached list of properties if
                // the component is not the same as the last queried one.

                // TODO: verify if this can be solved by deriving from IResettableConverter
                _properties    = null;
                _lastComponent = component;
            }

            if (_properties == null)
            {
                EditingContext editingContext = null;
                foreach (var typeDescriptor in PropertyWindowViewModelHelper.GetObjectsFromSelection <ObjectDescriptor>(context.Instance))
                {
                    editingContext = typeDescriptor.EditingContext;
                    break;
                }

                Debug.Assert(editingContext != null);

                if (editingContext != null)
                {
                    _properties = new PropertyDescriptorCollection(null);

                    // get list of properties through reflection
                    PropertyWindowViewModelHelper.AddReflectedProperties(_properties, component, attributes, editingContext);

                    // add properties from extender objects
                    PropertyWindowViewModelHelper.AddExtendedProperties(
                        component as IHavePropertyExtenders, _properties, attributes, editingContext);
                }
            }

            return(PropertyWindowViewModelHelper.GetBrowsableProperties(_properties));
        }