public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            var props = new PropertyDescriptorCollection(null);

            var processor = value as ProcessorTypeDescription;

            if (context.Instance is Array)
            {
                var array = context.Instance as object[];

                foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(value, attributes, true))
                {
                    props.Add(new MultiTargetPropertyDescriptor(prop.Name, prop.PropertyType, prop.ComponentType, prop, array));
                }

                var paramArray = array.Select(e => ((ContentItem)e).ProcessorParams).ToArray();

                foreach (var p in processor.Properties)
                {
                    var prop = new OpaqueDataDictionaryElementPropertyDescriptor(p.Name,
                                                                                 p.Type,
                                                                                 null);
                    var prop2 = new MultiTargetPropertyDescriptor(prop.Name,
                                                                  prop.PropertyType,
                                                                  prop.ComponentType,
                                                                  prop,
                                                                  paramArray);
                    props.Add(prop2);
                }
            }
            else
            {
                var contentItem = context.Instance as ContentItem;

                if (value == PipelineTypes.MissingProcessor)
                {
                    props.Add(new ReadonlyPropertyDescriptor("Name", typeof(string), typeof(ProcessorTypeDescription), contentItem.ProcessorName));

                    foreach (var p in contentItem.ProcessorParams)
                    {
                        var desc = new OpaqueDataDictionaryElementPropertyDescriptor(p.Key,
                                                                                     p.Value.GetType(),
                                                                                     contentItem.ProcessorParams);


                        props.Add(desc);
                    }
                }
                else
                {
                    // Emit regular properties.
                    foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(value, attributes, true))
                    {
                        props.Add(prop);
                    }

                    // Emit processor parameters.
                    foreach (var p in processor.Properties)
                    {
                        var desc = new OpaqueDataDictionaryElementPropertyDescriptor(p.Name,
                                                                                     p.Type,
                                                                                     contentItem.ProcessorParams);

                        props.Add(desc);
                    }
                }
            }

            return(props);
        }
Ejemplo n.º 2
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            var props = new PropertyDescriptorCollection(null);

            var processor = value as ProcessorTypeDescription;

            if (context.Instance is Array)
            {
                var array = context.Instance as object[];

                foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(value, attributes, true))
                    props.Add(new MultiTargetPropertyDescriptor(prop.Name, prop.PropertyType, prop.ComponentType, prop, array));

                var paramArray = array.Select(e => ((ContentItem)e).ProcessorParams).ToArray();

                foreach (var p in processor.Properties)
                {
                    var prop = new OpaqueDataDictionaryElementPropertyDescriptor(p.Name,
                                                                                 p.Type,
                                                                                 null);
                    var prop2 = new MultiTargetPropertyDescriptor(prop.Name,
                                                             prop.PropertyType,
                                                             prop.ComponentType,
                                                             prop,
                                                             paramArray);
                    props.Add(prop2);
                }
            }
            else
            {
                var contentItem = context.Instance as ContentItem;

                if (value == PipelineTypes.MissingProcessor)
                {

                    props.Add(new ReadonlyPropertyDescriptor("Name", typeof (string), typeof (ProcessorTypeDescription), contentItem.ProcessorName));

                    foreach (var p in contentItem.ProcessorParams)
                    {
                        var desc = new OpaqueDataDictionaryElementPropertyDescriptor(p.Key,
                                                                                     p.Value.GetType(),
                                                                                     contentItem.ProcessorParams);


                        props.Add(desc);
                    }
                }
                else
                {
                    // Emit regular properties.
                    foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(value, attributes, true))
                        props.Add(prop);

                    // Emit processor parameters.
                    foreach (var p in processor.Properties)
                    {
                        var desc = new OpaqueDataDictionaryElementPropertyDescriptor(p.Name,
                                                                                     p.Type,
                                                                                     contentItem.ProcessorParams);

                        props.Add(desc);
                    }
                }
            }

            return props;
        }