/
ConfigurationPropertyAttribute.cs
53 lines (45 loc) · 1.7 KB
/
ConfigurationPropertyAttribute.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Configuration
{
[AttributeUsage(AttributeTargets.Property)]
public sealed class ConfigurationPropertyAttribute : Attribute
{
internal const string DefaultCollectionPropertyName = "";
public ConfigurationPropertyAttribute(string name)
{
Name = name;
}
public string Name { get; }
public object DefaultValue { get; set; } = ConfigurationElement.s_nullPropertyValue;
public ConfigurationPropertyOptions Options { get; set; } = ConfigurationPropertyOptions.None;
public bool IsDefaultCollection
{
get { return (Options & ConfigurationPropertyOptions.IsDefaultCollection) != 0; }
set
{
if (value) Options |= ConfigurationPropertyOptions.IsDefaultCollection;
else
Options &= ~ConfigurationPropertyOptions.IsDefaultCollection;
}
}
public bool IsRequired
{
get { return (Options & ConfigurationPropertyOptions.IsRequired) != 0; }
set
{
if (value) Options |= ConfigurationPropertyOptions.IsRequired;
else Options &= ~ConfigurationPropertyOptions.IsRequired;
}
}
public bool IsKey
{
get { return (Options & ConfigurationPropertyOptions.IsKey) != 0; }
set
{
if (value) Options |= ConfigurationPropertyOptions.IsKey;
else Options &= ~ConfigurationPropertyOptions.IsKey;
}
}
}
}