Exemplo n.º 1
0
            public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                var properties = new PropertyDescriptorCollection(new PropertyDescriptor[0]).Cast <PropertyDescriptor>().ToList();

                var settings = (IBindingSettings)value;

                if (settings.IsConfigured())
                {
                    properties.AddRange(DesignComponentTypeDescriptor <TValue, IBindingSettings> .GetComponentProperties(
                                            this.ProjectTypeProvider, this.Components, settings.TypeId));
                }

                return(new PropertyDescriptorCollection(properties.ToArray()));
            }
Exemplo n.º 2
0
            /// <summary>
            /// Returns the properties for this instance of a component using the attribute array as a filter.
            /// </summary>
            /// <param name="attributes">An array of type Attribute that is used as a filter.</param>
            /// <returns>
            /// An array of type Attribute that represents the properties for this component instance that match the given set of attributes.
            /// </returns>
            public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
            {
                var properties = base.GetProperties(attributes).Cast <PropertyDescriptor>().ToList();

                var commandSettings = (CommandSettings)this.ModelElement;

                if (commandSettings != null)
                {
                    var projectTypeProvider = commandSettings.Store.GetService <INuPatternProjectTypeProvider>();
                    var components          = commandSettings.Store.GetService <INuPatternCompositionService>()
                                              .GetExports <ICommand, IComponentMetadata>();

                    // Remove the descriptor for the 'Properties 'property
                    properties.Remove(properties
                                      .First(descriptor => descriptor.Name == Reflector <CommandSettings> .GetPropertyName(x => x.Properties)));

                    // Add CommandSettings properties
                    properties.AddRange(DesignComponentTypeDescriptor <ICommand, CommandSettings> .GetComponentProperties(
                                            projectTypeProvider, components, commandSettings.TypeId));
                }

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