System.ComponentModel.AttributeCollection.CopyTo C# (CSharp) Method

CopyTo() public method

public CopyTo ( Array array, int index ) : void
array System.Array
index int
return void
        public void CopyTo(Array array, int index)
        {
            Array.Copy(_attributes, 0, array, index, _attributes.Length);
        }

Usage Example

        /// <include file='doc\RepeaterDesigner.uex' path='docs/doc[@for="RepeaterDesigner.PreFilterProperties"]/*' />
        /// <devdoc>
        ///   Filter the properties to replace the runtime DataSource property
        ///   descriptor with the designer's.
        /// </devdoc>
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);

            PropertyDescriptor prop;

            prop = (PropertyDescriptor)properties["DataSource"];
            Debug.Assert(prop != null);

            // we can't create the designer DataSource property based on the runtime property since theie
            // types do not match. Therefore, we have to copy over all the attributes from the runtime
            // and use them that way.
            AttributeCollection runtimeAttributes = prop.Attributes;

            Attribute[] attrs = new Attribute[runtimeAttributes.Count + 1];

            runtimeAttributes.CopyTo(attrs, 0);
            attrs[runtimeAttributes.Count] = new TypeConverterAttribute(typeof(DataSourceConverter));
            prop = TypeDescriptor.CreateProperty(this.GetType(), "DataSource", typeof(string),
                                                 attrs);
            properties["DataSource"] = prop;

            prop = (PropertyDescriptor)properties["DataMember"];
            Debug.Assert(prop != null);
            prop = TypeDescriptor.CreateProperty(this.GetType(), prop,
                                                 new Attribute[] {
                new TypeConverterAttribute(typeof(DataMemberConverter))
            });
            properties["DataMember"] = prop;
        }
All Usage Examples Of System.ComponentModel.AttributeCollection::CopyTo