-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
ConfigurationCollectionAttribute.xml
366 lines (322 loc) · 21.4 KB
/
ConfigurationCollectionAttribute.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<Type Name="ConfigurationCollectionAttribute" FullName="System.Configuration.ConfigurationCollectionAttribute">
<TypeSignature Language="C#" Value="public sealed class ConfigurationCollectionAttribute : Attribute" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit ConfigurationCollectionAttribute extends System.Attribute" />
<TypeSignature Language="DocId" Value="T:System.Configuration.ConfigurationCollectionAttribute" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class ConfigurationCollectionAttribute
Inherits Attribute" />
<TypeSignature Language="F#" Value="type ConfigurationCollectionAttribute = class
 inherit Attribute" />
<TypeSignature Language="C++ CLI" Value="public ref class ConfigurationCollectionAttribute sealed : Attribute" />
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="System.Configuration.ConfigurationManager" FromVersion="9.0.0.0" To="System.Configuration" ToVersion="4.0.0.0" FrameworkAlternate="netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Attribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Property)]</AttributeName>
<AttributeName Language="F#">[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Property)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Declaratively instructs .NET to create an instance of a configuration element collection. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You use the <xref:System.Configuration.ConfigurationCollectionAttribute> attribute to decorate a <xref:System.Configuration.ConfigurationElementCollection> element. This instructs .NET to create an instance of the collection and to initialize it using your custom <xref:System.Configuration.ConfigurationElement> values.
> [!NOTE]
> 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 <xref:System.Configuration.ConfigurationCollectionAttribute> attribute. For each element marked with this attribute, .NET uses reflection to read the decorating parameters and create a related <xref:System.Configuration.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 <xref:System.Configuration.ConfigurationElementCollection> member and return the properties collection.
The .NET configuration system provides attribute types that you can use during the creation of custom configuration elements. There are two kinds of attributes:
- The attributes that instruct .NET how to create instances of the custom configuration element properties. These types include:
- <xref:System.Configuration.ConfigurationCollectionAttribute>
- <xref:System.Configuration.ConfigurationPropertyAttribute>
- The attributes that instruct .NET how to validate the custom configuration element properties. These types include:
- <xref:System.Configuration.IntegerValidatorAttribute>
- <xref:System.Configuration.LongValidatorAttribute>
- <xref:System.Configuration.RegexStringValidatorAttribute>
- <xref:System.Configuration.StringValidatorAttribute>
- <xref:System.Configuration.TimeSpanValidatorAttribute>
## Examples
The following example shows how to use the <xref:System.Configuration.ConfigurationCollectionAttribute>.
This example consists of three classes: `UrlsSection`, `UrlsCollection`, and `UrlConfigElement`. The `UrlsSection` class uses the <xref:System.Configuration.ConfigurationCollectionAttribute> to define a custom configuration section. This section contains a URL collection (defined by the `UrlsCollection` class) of URL elements (defined by the `UrlConfigElement` class). When you run the example, an instance of the `UrlsSection` class is created and the following configuration elements are generated in the application configuration file:
```xml
<configuration>
<configSections>
<section name="MyUrls" type="UrlsSection,
ConfigurationCollectionAttribute, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</configSections>
<MyUrls>
<urls>
<remove name="Contoso" />
<add name="Contoso" url="http://www.contoso.com" port="0" />
</urls>
</MyUrls>
</configuration
```
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/CS/customcollectionsection.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/VB/customcollectionsection.vb" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/CS/configurationcollectionattribute.cs" id="Snippet31":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/VB/configurationcollectionattribute.vb" id="Snippet31":::
]]></format>
</remarks>
<altmember cref="T:System.Configuration.ConfigurationPropertyAttribute" />
<altmember cref="T:System.Configuration.IntegerValidatorAttribute" />
<altmember cref="T:System.Configuration.LongValidatorAttribute" />
<altmember cref="T:System.Configuration.RegexStringValidatorAttribute" />
<altmember cref="T:System.Configuration.StringValidatorAttribute" />
<altmember cref="T:System.Configuration.TimeSpanValidatorAttribute" />
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ConfigurationCollectionAttribute (Type itemType);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Type itemType) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Configuration.ConfigurationCollectionAttribute.#ctor(System.Type)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (itemType As Type)" />
<MemberSignature Language="F#" Value="new System.Configuration.ConfigurationCollectionAttribute : Type -> System.Configuration.ConfigurationCollectionAttribute" Usage="new System.Configuration.ConfigurationCollectionAttribute itemType" />
<MemberSignature Language="C++ CLI" Value="public:
 ConfigurationCollectionAttribute(Type ^ itemType);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="itemType" Type="System.Type" />
</Parameters>
<Docs>
<param name="itemType">The type of the property collection to create.</param>
<summary>Initializes a new instance of the <see cref="T:System.Configuration.ConfigurationCollectionAttribute" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You use this constructor to tell the .NET Framework the custom type of the property collection to be created.
## Examples
The following example shows how to use the <xref:System.Configuration.ConfigurationCollectionAttribute.%23ctor%2A>.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/CS/customcollectionsection.cs" id="Snippet20":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/VB/customcollectionsection.vb" id="Snippet20":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="itemType" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="AddItemName">
<MemberSignature Language="C#" Value="public string AddItemName { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string AddItemName" />
<MemberSignature Language="DocId" Value="P:System.Configuration.ConfigurationCollectionAttribute.AddItemName" />
<MemberSignature Language="VB.NET" Value="Public Property AddItemName As String" />
<MemberSignature Language="F#" Value="member this.AddItemName : string with get, set" Usage="System.Configuration.ConfigurationCollectionAttribute.AddItemName" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ AddItemName { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the name of the <see langword="<add>" /> configuration element.</summary>
<value>The name that substitutes the standard name "add" for the configuration item.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Configuration.ConfigurationCollectionAttribute.AddItemName%2A> property allows you to assign a different name to the configuration element. For example, you could use `addUrl` instead of "add".
## Examples
The following example shows how to use the <xref:System.Configuration.ConfigurationCollectionAttribute.AddItemName%2A> property.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/CS/customcollectionsection.cs" id="Snippet20":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/VB/customcollectionsection.vb" id="Snippet20":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="ClearItemsName">
<MemberSignature Language="C#" Value="public string ClearItemsName { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string ClearItemsName" />
<MemberSignature Language="DocId" Value="P:System.Configuration.ConfigurationCollectionAttribute.ClearItemsName" />
<MemberSignature Language="VB.NET" Value="Public Property ClearItemsName As String" />
<MemberSignature Language="F#" Value="member this.ClearItemsName : string with get, set" Usage="System.Configuration.ConfigurationCollectionAttribute.ClearItemsName" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ ClearItemsName { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the name for the <see langword="<clear>" /> configuration element.</summary>
<value>The name that replaces the standard name "clear" for the configuration item.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Configuration.ConfigurationCollectionAttribute.ClearItemsName%2A> property allows you to assign a different name to the `<clear>` configuration element. For example, you could use `clearUrls` instead of "clear".
## Examples
The following example shows how to use the <xref:System.Configuration.ConfigurationCollectionAttribute.ClearItemsName%2A>.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/CS/customcollectionsection.cs" id="Snippet20":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/VB/customcollectionsection.vb" id="Snippet20":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="CollectionType">
<MemberSignature Language="C#" Value="public System.Configuration.ConfigurationElementCollectionType CollectionType { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Configuration.ConfigurationElementCollectionType CollectionType" />
<MemberSignature Language="DocId" Value="P:System.Configuration.ConfigurationCollectionAttribute.CollectionType" />
<MemberSignature Language="VB.NET" Value="Public Property CollectionType As ConfigurationElementCollectionType" />
<MemberSignature Language="F#" Value="member this.CollectionType : System.Configuration.ConfigurationElementCollectionType with get, set" Usage="System.Configuration.ConfigurationCollectionAttribute.CollectionType" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Configuration::ConfigurationElementCollectionType CollectionType { System::Configuration::ConfigurationElementCollectionType get(); void set(System::Configuration::ConfigurationElementCollectionType value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Configuration.ConfigurationElementCollectionType</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the type of the <see cref="T:System.Configuration.ConfigurationCollectionAttribute" /> attribute.</summary>
<value>The type of the <see cref="T:System.Configuration.ConfigurationCollectionAttribute" />.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="ItemType">
<MemberSignature Language="C#" Value="public Type ItemType { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Type ItemType" />
<MemberSignature Language="DocId" Value="P:System.Configuration.ConfigurationCollectionAttribute.ItemType" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property ItemType As Type" />
<MemberSignature Language="F#" Value="member this.ItemType : Type" Usage="System.Configuration.ConfigurationCollectionAttribute.ItemType" />
<MemberSignature Language="C++ CLI" Value="public:
 property Type ^ ItemType { Type ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Type</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the type of the collection element.</summary>
<value>The type of the collection element.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Configuration.ConfigurationCollectionAttribute.ItemType%2A> property is used by reflection to get the configuration element type.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="RemoveItemName">
<MemberSignature Language="C#" Value="public string RemoveItemName { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string RemoveItemName" />
<MemberSignature Language="DocId" Value="P:System.Configuration.ConfigurationCollectionAttribute.RemoveItemName" />
<MemberSignature Language="VB.NET" Value="Public Property RemoveItemName As String" />
<MemberSignature Language="F#" Value="member this.RemoveItemName : string with get, set" Usage="System.Configuration.ConfigurationCollectionAttribute.RemoveItemName" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ RemoveItemName { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the name for the <see langword="<remove>" /> configuration element.</summary>
<value>The name that replaces the standard name "remove" for the configuration element.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Configuration.ConfigurationCollectionAttribute.RemoveItemName%2A> property allows you to assign a different name to the `<remove>` configuration element. For example, you could use `removeUrl` instead of "remove".
## Examples
The following example shows how to use the <xref:System.Configuration.ConfigurationCollectionAttribute.RemoveItemName%2A> property.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/CS/customcollectionsection.cs" id="Snippet20":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationCollectionAttribute/VB/customcollectionsection.vb" id="Snippet20":::
]]></format>
</remarks>
</Docs>
</Member>
</Members>
</Type>