Export (0) Print
Expand All

ConfigurationCollectionAttribute Class

Declaratively instructs the .NET Framework to create an instance of a configuration element collection. This class cannot be inherited.

Namespace: System.Configuration
Assembly: System.Configuration (in system.configuration.dll)

[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Property)] 
public ref class ConfigurationCollectionAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Property) */ 
public final class ConfigurationCollectionAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Property) 
public final class ConfigurationCollectionAttribute extends Attribute
Not applicable.

You use the ConfigurationCollectionAttribute attribute to decorate a ConfigurationElementCollection element. This instructs the .NET Framework to create an instance of the collection and to initialize it using your custom ConfigurationElement values.

NoteNote:

The simplest way to create a custom configuration element is to use the attributed (declarative) model. You declare the elements and decorate them with the ConfigurationCollectionAttribute attribute. For each element marked with this attribute, the .NET Framework uses reflection to read the decorating parameters and create a related ConfigurationElementCollection instance. You can also use the programmatic model. In this case it is your responsibility to declare the custom public collection but also to override the ConfigurationElementCollection member and return the properties collection.

The .NET Framework configuration system provides attribute types that you can use during the creation of custom configuration elements. There are two kinds of attributes:

The following example shows how to use the ConfigurationCollectionAttribute.

The example contains four classes. The class TestingConfigurationCollectionAttribute creates a custom configuration section that contains a collection of elements. The other three classes are used to create the custom section. The custom section type UrlsSection contains an Urls property. This property is a custom collection of type UrlsCollection that contains custom elements of type UrlConfigElement. The example code writes the custom configuration section to the application configuration file. The key for this example is the Urls property, decorated with the ConfigurationCollectionAttribute.

No code example is currently available or this language may not be supported.

System.Object
   System.Attribute
    System.Configuration.ConfigurationCollectionAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft