示例#1
0
        protected virtual void PopulateMapping(ITypeDescriptorContext context)
        {
            if (context != null)
            {
                _context = context;
            }
            Debug.Assert(_context != null, "Should have a context for the PopulateMapping call.");

            foreach (var selectedObj in PropertyWindowViewModelHelper.GetObjectsFromSelection <TSelectedObj>(_context.Instance))
            {
                PopulateMappingForSelectedObject(selectedObj);
                break;
            }
        }
示例#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));
        }