// This method returns the StatFunction properties as defined by the "parent"
        // DataGridCollectionView as well as the other "standard" properties for this class.
        // The StatFunction properties are NOT filtered by the specified attributes.
        PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
        {
            if (attributes == null)
            {
                // We only cache the full property list.
                if (m_classProperties == null)
                {
                    DataGridCollectionView view = this.GetCollectionView();

                    Debug.Assert(view != null, "A group should always have a parent CollectionView for the StatFunctions to work.");

                    if (view == null)
                    {
                        return(TypeDescriptor.GetProperties(typeof(DataGridCollectionViewGroup)));
                    }

                    PropertyDescriptorCollection classProperties = TypeDescriptor.GetProperties(typeof(DataGridCollectionViewGroup));
                    PropertyDescriptor[]         properties      = new PropertyDescriptor[classProperties.Count];
                    classProperties.CopyTo(properties, 0);

                    m_classProperties = new PropertyDescriptorCollection(properties);
                }

                return(m_classProperties);
            }
            else
            {
                PropertyDescriptorCollection props = TypeDescriptor.GetProperties(this, attributes);
                DataGridCollectionView       view  = this.GetCollectionView();

                return(props);
            }
        }
    //This method will add the additional properties to the object.
    //It helps to think of the various PropertyDescriptors are columns in a database table
    public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
    {
        PropertyDescriptorCollection cols = base.GetProperties(attributes);
        string propName = "";     //empty string to be populated later

        //find the matching property in the type being called.
        foreach (PropertyDescriptor col in cols)
        {
            if (col.PropertyType.Name == typeProp.Name)
            {
                propName = col.Name;
            }
        }
        PropertyDescriptor           pd       = cols[propName];
        PropertyDescriptorCollection children = pd.GetChildProperties();     //expand the child object

        PropertyDescriptor[] propDescripts = new PropertyDescriptor[cols.Count + children.Count];
        int count = cols.Count;     //start adding at the last index of the array

        cols.CopyTo(propDescripts, 0);
        //creation of the 'descriptor strings'
        foreach (PropertyDescriptor cpd in children)
        {
            propDescripts[count] = new SubPropertyDescriptor(pd, cpd, pd.Name + "_" + cpd.Name);
            count++;
        }
        PropertyDescriptorCollection newCols = new PropertyDescriptorCollection(propDescripts);

        return(newCols);
    }
示例#3
0
            public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                PropertyDescriptorCollection props = base.GetProperties(context, value, attributes);
                PSParamType        parm            = value as PSParamType;
                List <PSParameter> psprops         = null;
                int propcnt = props.Count;

                if (null != parm)
                {
                    psprops  = parm.Properties;
                    propcnt += psprops.Count;
                }
                PropertyDescriptor[] psdescs = new PropertyDescriptor[propcnt];
                props.CopyTo(psdescs, 0);

                if (null != psprops)
                {
                    int idx = props.Count;
                    foreach (PSParameter psparam in psprops)
                    {
                        psdescs[idx++] = new PSParamDescriptor(psparam);
                    }
                }
                return(new PropertyDescriptorCollection(psdescs));
            }
示例#4
0
            static PropertyDescriptor[] ToArray(PropertyDescriptorCollection properties)
            {
                var result = new PropertyDescriptor[properties.Count];

                properties.CopyTo(result, 0);
                return(result);
            }
示例#5
0
        /// <summary>
        /// This is overridden to return a property descriptors for the object represented by this type
        /// descriptor along with extra property descriptors for its child properties.
        /// </summary>
        /// <param name="attributes">An array of attributes to use as a filter or null for no filter</param>
        /// <returns>Returns a <see cref="PropertyDescriptorCollection"/> that contains property descriptors for
        /// the object and its child properties.</returns>
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            // This seems to ignore the filter so GetChildProperties() will get rid of all non-browsable
            // properties.
            PropertyDescriptorCollection props    = base.GetProperties(attributes);
            List <PropertyDescriptor>    newProps = new List <PropertyDescriptor>();

            this.GetChildProperties(null, String.Empty, attributes, props, newProps);

            if (newProps.Count != 0)
            {
                // The collection is read-only so we'll need to create a new one
                PropertyDescriptor[] tempProps = new PropertyDescriptor[props.Count + newProps.Count];

                props.CopyTo(tempProps, 0);
                newProps.CopyTo(tempProps, props.Count);

                props = new PropertyDescriptorCollection(tempProps);

                // Now we'll remove hidden top-level properties
                for (int idx = 0; idx < props.Count; idx++)
                {
                    if (props[idx].Attributes[typeof(HidePropertyAttribute)] != null)
                    {
                        props.RemoveAt(idx);
                        idx--;
                    }
                }
            }

            return(props);
        }
        private PropertyDescriptorCollection FilterProperties(PropertyDescriptorCollection props)
        {
            // create a new property array, PropertyDescriptorCollection is read-only here.
            PropertyDescriptor[] propArray = new PropertyDescriptor[props.Count];

            props.CopyTo(propArray, 0);

            bool changed = false;

            // run through the list, replacing as necessary
            //
            for (int i = 0; i < propArray.Length; i++)
            {
                PropertyDescriptor newProp = ProcessProperty(propArray[i]);
                if (newProp != propArray[i])
                {
                    changed      = true;
                    propArray[i] = newProp;
                }
            }

            // build the new collection if we made a change.
            //
            if (changed)
            {
                props = new PropertyDescriptorCollection(propArray);
            }
            return(props);
        }
示例#7
0
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection cols = base.GetProperties(attributes);

            string propertyName = "";

            foreach (PropertyDescriptor col in cols)
            {
                if (col.PropertyType.Name == typeProperty.Name)
                {
                    propertyName = col.Name;
                }
            }
            PropertyDescriptor           pd       = cols[propertyName];
            PropertyDescriptorCollection children = pd.GetChildProperties();

            PropertyDescriptor[] array = new PropertyDescriptor[cols.Count + children.Count];
            int count = cols.Count;

            cols.CopyTo(array, 0);

            foreach (PropertyDescriptor cpd in children)
            {
                array[count] = new SubPropertyDescriptor(pd, cpd, pd.Name + "_" + cpd.Name);
                count++;
            }

            PropertyDescriptorCollection newcols = new PropertyDescriptorCollection(array);

            return(newcols);
        }
示例#8
0
        public override PropertyDescriptorCollection GetProperties()
        {
            var properties = new PropertyDescriptor[m_MergedProperties.Count];

            m_MergedProperties.CopyTo(properties, 0);
            return(new PropertyDescriptorCollection(properties));
        }
示例#9
0
        static ProviderBase()
        {
            PropertyDescriptorCollection propertyCollection = TypeDescriptor.GetProperties(typeof(ProviderBase));

            PropertyDescriptor[] properties = new PropertyDescriptor[propertyCollection.Count];
            propertyCollection.CopyTo(properties, 0);
            _providerBaseTypeProperties = new PropertyDescriptorCollection(properties, false);
        }
示例#10
0
        private void CreateProperties()
        {
            PropertyDescriptor[] descArray = new PropertyDescriptor[thisProperties.Count + controlProperties.Count];
            thisProperties.CopyTo(descArray, 0);
            controlProperties.CopyTo(descArray, thisProperties.Count);

            properties = new PropertyDescriptorCollection(descArray);
        }
示例#11
0
        /// <summary>
        /// Obtains the default properties for an object</summary>
        /// <param name="owner">Object whose properties are obtained</param>
        /// <returns>Default properties for an object, as an array</returns>
        public static PropertyDescriptor[] GetDefaultProperties2(object owner)
        {
            PropertyDescriptorCollection propertyCollection = GetDefaultProperties(owner);

            PropertyDescriptor[] result = new PropertyDescriptor[propertyCollection.Count];
            propertyCollection.CopyTo(result, 0);
            return(result);
        }
示例#12
0
        static LayerCollection()
        {
            PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(ILayer));

            PropertyDescriptor[] propsArray = new PropertyDescriptor[props.Count];
            props.CopyTo(propsArray, 0);

            _layerProperties = new PropertyDescriptorCollection(propsArray, true);
        }
示例#13
0
        PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this, attributes, true);

            PropertyDescriptor[] proparray = new PropertyDescriptor[properties.Count];
            properties.CopyTo(proparray, 0);
            // Wrap the properties in our custom collection.
            return(new CustomProperties(proparray));
        }
示例#14
0
        private void ensureInstanceProperties()
        {
            if (_instanceProperties != null)
            {
                return;
            }

            PropertyDescriptor[] propArray = new PropertyDescriptor[_layerTypeProperties.Count];
            _layerTypeProperties.CopyTo(propArray, 0);
            _instanceProperties = new PropertyDescriptorCollection(propArray, false);
        }
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection orig = TypeDescriptor.GetProperties(GetType(), attributes);

            PropertyDescriptor[] arr = new PropertyDescriptor[orig.Count];
            orig.CopyTo(arr, 0);
            PropertyDescriptorCollection col = new PropertyDescriptorCollection(arr);

            ModifyProperties(col);
            return(col);
        }
 public static void AddProperty(string name, Type type, params Attribute[] attributes)
 {
     lock (syncLock)
     {       // append the new prop, into a *new* collection, so that downstream
             // callers don't have to worry about the complexities
         PropertyDescriptor[] newProps = new PropertyDescriptor[props.Count + 1];
         props.CopyTo(newProps, 0);
         newProps[newProps.Length - 1] = new PropertyBagPropertyDescriptor(name, type, attributes);
         props = new PropertyDescriptorCollection(newProps, true);
     }
 }
    private static PropertyDescriptorCollection AddItems(PropertyDescriptorCollection cols, params PropertyDescriptor[] items)
    {
        PropertyDescriptor[] array = new PropertyDescriptor[cols.Count + items.Length];
        cols.CopyTo(array, 0);
        for (int i = 0; i < items.Length; i++)
        {
            array[cols.Count + i] = items[i];
        }
        PropertyDescriptorCollection newcols = new PropertyDescriptorCollection(array);

        return(newcols);
    }
示例#18
0
        protected ReadOnlyCollection <PropertyDescriptor> GetPropertiesROCollection()
        {
            PropertyDescriptorCollection properties = GetProperties();

            PropertyDescriptor[] pds = new PropertyDescriptor[PropertyDescriptorCount];

            properties.CopyTo(pds, 0);

            ReadOnlyCollection <PropertyDescriptor> result = new ReadOnlyCollection <PropertyDescriptor>(pds);

            return(result);
        }
示例#19
0
        private void ensureInstanceProperties()
        {
            if (_instanceProperties != null)
            {
                return;
            }

            PropertyDescriptorCollection classProperties = GetClassProperties();

            PropertyDescriptor[] propArray = new PropertyDescriptor[classProperties.Count];
            classProperties.CopyTo(propArray, 0);
            _instanceProperties = new PropertyDescriptorCollection(propArray, false);
        }
示例#20
0
            public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, attributes);

                if ((properties != null) && (properties.Count > 0))
                {
                    properties = properties.Sort();
                    PropertyDescriptor[] array = new PropertyDescriptor[properties.Count];
                    properties.CopyTo(array, 0);
                    properties = new PropertyDescriptorCollection(array, true);
                }
                return(properties);
            }
示例#21
0
        public void GetListNameAccessors()
        {
            List <SimpleClass> list = new List <SimpleClass>();
            ObjectListView     view = new ObjectListView(list);

            // Get some random property descriptors.
            PropertyDescriptorCollection accessors = TypeDescriptor.GetProperties(typeof(ISite));

            PropertyDescriptor[] listAccessors = new PropertyDescriptor[accessors.Count];
            accessors.CopyTo(listAccessors, 0);

            Assert.AreEqual("", ((ITypedList)view).GetListName(listAccessors));
        }
示例#22
0
        public void GetListNameAccessors()
        {
            ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IList();

            ObjectListView <SimpleClass> view = factory.View;

            // Get some random property descriptors.
            PropertyDescriptorCollection accessors = TypeDescriptor.GetProperties(typeof(ISite));

            PropertyDescriptor[] listAccessors = new PropertyDescriptor[accessors.Count];
            accessors.CopyTo(listAccessors, 0);

            Assert.AreEqual("", ((ITypedList)view).GetListName(listAccessors));
        }
示例#23
0
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection cols         = base.GetProperties();
            PropertyDescriptor           prncpl       = cols["Principal"];
            PropertyDescriptorCollection prncpl_child = prncpl.GetChildProperties();

            PropertyDescriptor[] arr = new PropertyDescriptor[cols.Count + 4];
            cols.CopyTo(arr, 0);
            arr[cols.Count]     = new SubPropertyDescriptor(prncpl, prncpl_child["ID"], "Principal_ID");
            arr[cols.Count + 1] = new SubPropertyDescriptor(prncpl, prncpl_child["Name"], "Principal_Name");
            arr[cols.Count + 2] = new SubPropertyDescriptor(prncpl, prncpl_child["Status"], "Principal_Status");
            arr[cols.Count + 3] = new SubPropertyDescriptor(prncpl, prncpl_child["Members"], "Principal_Members");
            PropertyDescriptorCollection newcols = new PropertyDescriptorCollection(arr);

            return(newcols);
        }
        private void InitializeInheritedProperties(bool rootComponent)
        {
            Hashtable props = new Hashtable();

            bool readOnlyInherit = (InheritanceAttribute.Equals(InheritanceAttribute.InheritedReadOnly));

            if (!readOnlyInherit)
            {
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(Component);

                // Now loop through all the properties.  For each one, try to match a pre-created property.
                // If that fails, then create a new property.
                //
                PropertyDescriptor[] values = new PropertyDescriptor[properties.Count];
                properties.CopyTo(values, 0);

                for (int i = 0; i < values.Length; i++)
                {
                    PropertyDescriptor prop = values[i];

                    // Skip some properties
                    //
                    if (object.Equals(prop.Attributes[typeof(DesignOnlyAttribute)], DesignOnlyAttribute.Yes))
                    {
                        continue;
                    }

                    if (prop.SerializationVisibility == DesignerSerializationVisibility.Hidden && !prop.IsBrowsable)
                    {
                        continue;
                    }

                    PropertyDescriptor inheritedProp = (PropertyDescriptor)props[prop.Name];

                    if (inheritedProp == null)
                    {
                        // This ia a publicly inherited component.  We replace all component properties with
                        // inherited versions that reset the default property values to those that are
                        // currently on the component.
                        //
                        props[prop.Name] = new InheritedPropertyDescriptor(prop, component, rootComponent);
                    }
                }
            }

            inheritedProps = props;
        }
        protected override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection descriptors          = base.GetProperties(attributes);
            PropertyDescriptor           dataSourceDescriptor = descriptors.Find("DataSource", true);

            if (dataSourceDescriptor != null)
            {
                int index = descriptors.IndexOf(dataSourceDescriptor);
                PropertyDescriptor[] descriptorArray = new PropertyDescriptor[descriptors.Count];
                descriptors.CopyTo(descriptorArray, 0);
                descriptorArray[index] = new DynamicPropertyDescriptor(dataSourceDescriptor, new TypeConverterAttribute(typeof(DataSourceConverter)));
                (descriptorArray[index] as DynamicPropertyDescriptor).CanResetValueHandler = new CanResetValueHandler(CanResetDataSource);
                (descriptorArray[index] as DynamicPropertyDescriptor).ResetValueHandler    = new ResetValueHandler(ResetDataSource);
                descriptors = new PropertyDescriptorCollection(descriptorArray, true);
            }
            return(descriptors);
        }
示例#26
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes)
        {
            //IEventBindingService eventPropertyService = this.GetEventPropertyService(component, context);
            //if (eventPropertyService == null)
            //{
            //    return new PropertyDescriptorCollection(null);
            //}
            EventDescriptorCollection events = TypeDescriptor.GetEvents(component, attributes);
            // PropertyDescriptorCollection eventProperties = eventPropertyService.GetEventProperties(events);
            PropertyDescriptorCollection eventProperties = GetEventProperties(events);

            Attribute[] destinationArray = new Attribute[attributes.Length + 1];
            Array.Copy(attributes, 0, destinationArray, 0, attributes.Length);
            destinationArray[attributes.Length] = DesignerSerializationVisibilityAttribute.Content;
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component, destinationArray);


            if (properties.Count > 0)
            {
                ArrayList list = null;
                for (int i = 0; i < properties.Count; i++)
                {
                    PropertyDescriptor oldPropertyDescriptor = properties[i];
                    if (oldPropertyDescriptor.Converter.GetPropertiesSupported() && (TypeDescriptor.GetEvents(oldPropertyDescriptor.GetValue(component), attributes).Count > 0))
                    {
                        if (list == null)
                        {
                            list = new ArrayList();
                        }
                        oldPropertyDescriptor = TypeDescriptor.CreateProperty(oldPropertyDescriptor.ComponentType, oldPropertyDescriptor, new Attribute[] { MergablePropertyAttribute.No });
                        list.Add(oldPropertyDescriptor);
                    }
                }
                if (list != null)
                {
                    PropertyDescriptor[] array = new PropertyDescriptor[list.Count];
                    list.CopyTo(array, 0);
                    PropertyDescriptor[] descriptorArray2 = new PropertyDescriptor[eventProperties.Count + array.Length];
                    eventProperties.CopyTo(descriptorArray2, 0);
                    Array.Copy(array, 0, descriptorArray2, eventProperties.Count, array.Length);
                    eventProperties = new PropertyDescriptorCollection(descriptorArray2);
                }
            }
            return(eventProperties);
        }
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection ps   = TypeDescriptor.GetProperties(this, attributes, true);
            List <PropertyDescriptor>    list = new List <PropertyDescriptor>();
            bool isString = typeof(string).Equals(_type);

            if (IsDataOnly)
            {
                foreach (PropertyDescriptor p in ps)
                {
                    if ((string.CompareOrdinal(p.Name, "DefaultData") == 0) || (string.CompareOrdinal(p.Name, "DataType") == 0))
                    {
                        PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(this.GetType(), p.Name, VPLUtil.ObjectToString(p.GetValue(this)), attributes);
                        list.Add(p0);
                    }
                }
            }
            else
            {
                if (isString)
                {
                    PropertyDescriptor[] a = new PropertyDescriptor[ps.Count];
                    ps.CopyTo(a, 0);
                    list.AddRange(a);
                }
                else
                {
                    //remove Encrypted if not a string value
                    foreach (PropertyDescriptor p in ps)
                    {
                        if (string.CompareOrdinal(p.Name, "Encrypted") != 0)
                        {
                            list.Add(p);
                        }
                    }
                }
            }

            PropertyInfo            pif = typeof(ConfigProperty).GetProperty("DefaultData");
            PropertyDescriptorValue pv  = new PropertyDescriptorValue("Data", attributes, pif, _type, typeof(ConfigProperty));

            list.Add(pv);
            ps = new PropertyDescriptorCollection(list.ToArray());
            return(ps);
        }
示例#28
0
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            if (_pdcFiltered == null)
            {
                PropertyDescriptorCollection pdc = base.GetProperties(attributes);  // this gives us a readonly collection, no good
                Array arr = Array.CreateInstance(typeof(PropertyDescriptor), pdc.Count);
                pdc.CopyTo(arr, 0);
                _pdcFiltered = new PropertyDescriptorCollection((PropertyDescriptor[])arr);
            }
            if (_methodInfo != null)
            {
                // invoke the method
                Object[] arrObj = { _pdcFiltered };

                object obj = _methodInfo.Invoke(_instance, arrObj);
            }
            return(_pdcFiltered);
        }
示例#29
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true);
            //
            List <PropertyDescriptor> list = new List <PropertyDescriptor>();

            PropertyDescriptor[] a = new PropertyDescriptor[ps.Count];
            ps.CopyTo(a, 0);
            list.AddRange(a);
            //
            foreach (ConfigProperty cp in _cat.Properties.Properties)
            {
                PropertyDescriptorConfig pc = new PropertyDescriptorConfig(cp.DataName, attributes, cp, _owner);
                list.Add(pc);
            }
            ps = new PropertyDescriptorCollection(list.ToArray());
            //
            return(ps);
        }
示例#30
0
 public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
 {
     if ((this.instance != null) && (this.collection == null))
     {
         PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.instance);
         PropertyDescriptor[]         array      = new PropertyDescriptor[properties.Count];
         properties.CopyTo(array, 0);
         this.collection = new PropertyDescriptorCollection(array, false);
     }
     if (this.collection.Count > 0)
     {
         this.propItems = this.collection["Items"];
         if (this.propItems != null)
         {
             this.collection.Remove(this.propItems);
         }
     }
     return(this.collection);
 }