ConfigurationProperty Class
Represents an attribute or a child of a configuration element. This class cannot be inherited.
Assembly: System.Configuration (in System.Configuration.dll)
The ConfigurationProperty type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ConfigurationProperty(String, Type) | Initializes a new instance of the ConfigurationProperty class. |
![]() | ConfigurationProperty(String, Type, Object) | Initializes a new instance of the ConfigurationProperty class. |
![]() | ConfigurationProperty(String, Type, Object, ConfigurationPropertyOptions) | Initializes a new instance of the ConfigurationProperty class. |
![]() | ConfigurationProperty(String, Type, Object, TypeConverter, ConfigurationValidatorBase, ConfigurationPropertyOptions) | Initializes a new instance of the ConfigurationProperty class. |
![]() | ConfigurationProperty(String, Type, Object, TypeConverter, ConfigurationValidatorBase, ConfigurationPropertyOptions, String) | Initializes a new instance of the ConfigurationProperty class. |
| Name | Description | |
|---|---|---|
![]() | Converter | Gets the TypeConverter used to convert this ConfigurationProperty into an XML representation for writing to the configuration file. |
![]() | DefaultValue | Gets the default value for this ConfigurationProperty property. |
![]() | Description | Gets the description associated with the ConfigurationProperty. |
![]() | IsAssemblyStringTransformationRequired | Indicates whether the assembly name for the configuration property requires transformation when it is serialized for an earlier version of the .NET Framework. |
![]() | IsDefaultCollection | Gets a value that indicates whether the property is the default collection of an element. |
![]() | IsKey | Gets a value indicating whether this ConfigurationProperty is the key for the containing ConfigurationElement object. |
![]() | IsRequired | Gets a value indicating whether this ConfigurationProperty is required. |
![]() | IsTypeStringTransformationRequired | Indicates whether the type name for the configuration property requires transformation when it is serialized for an earlier version of the .NET Framework. |
![]() | IsVersionCheckRequired | Indicates whether the configuration property's parent configuration section is queried at serialization time to determine whether the configuration property should be serialized into XML. |
![]() | Name | Gets the name of this ConfigurationProperty. |
![]() | Type | Gets the type of this ConfigurationProperty object. |
![]() | Validator | Gets the ConfigurationValidatorAttribute, which is used to validate this ConfigurationProperty object. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
In the case of a simple ConfigurationElement, such as the CustomSection shown in the next example, the ConfigurationProperty objects represent attributes such as fileName.
In the case of more complex configuration elements such as a section containing subsections, for instance authentication, the ConfigurationProperty objects can represent ConfigurationElement objects as well as attributes.
The ConfigurationPropertyCollection class represents the collection of the ConfigurationProperty objects that can be either attributes or ConfigurationElement objects of a configuration element.
The ConfigurationProperty class represents an individual configuration setting. This class allows you to get or set the name, type, and default value for a particular configuration entity (attribute or element) and specify whether the attribute is required, is an element key, or represents a default element collection.
Notes to ImplementersEvery ConfigurationElement object creates an internal ConfigurationPropertyCollection collection of ConfigurationProperty objects that represents either the element attributes or a collection of child elements.
Non-customizable information and functionality is contained by an ElementInformation object provided by the ElementInformation property.
You can use a programmatic or a declarative (attributed) coding model to create a custom configuration element.
Programmatic Model. This model requires that you create a property for each element attribute to get and/or set its value and add it to the internal property bag of the underlying ConfigurationElement base class.
Declarative Model. This simpler model, also called attributed model, allows you to define an element attribute by using a property and decorate it with attributes. These attributes instruct the ASP.NET configuration system about the property types and their default values. With this information, obtained through reflection, the ASP.NET configuration system creates the element property objects for you and performs the required initialization.
The following code example shows how to use the ConfigurationProperty when you create a custom section.
The following is an excerpt of the configuration file used by the code in the previous example.
<configuration>
<configSections>
<section name="CustomSection" type="ConfigurationPropertyExample.CustomSection, ConfigurationPropertyExample"
allowDefinition="Everywhere" allowExeDefinition="MachineToApplication"
restartOnExternalChanges="true" />
</configSections>
<CustomSection fileName="override.txt" alias="alias.txt"
maxUsers="1000" maxIdleTime="00:05:00" />
</configuration>
The following example shows how to create the previous section in code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
