Added tests for Task.WhenAll w/ empty list
[mono.git] / mcs / class / System.Configuration / System.Configuration / SectionInformation.cs
1 //
2 // System.Configuration.SectionInformation.cs
3 //
4 // Authors:
5 //      Duncan Mak (duncan@ximian.com)
6 //  Lluis Sanchez Gual (lluis@novell.com)
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
15 // 
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
18 // 
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //
27 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
28 //
29
30 #if NET_2_0
31 using System.Collections;
32 using System.Xml;
33
34 namespace System.Configuration
35 {
36         public sealed class SectionInformation
37         {
38                 ConfigurationSection parent;
39                 
40                 ConfigurationAllowDefinition allow_definition = ConfigurationAllowDefinition.Everywhere;
41                 ConfigurationAllowExeDefinition allow_exe_definition = ConfigurationAllowExeDefinition.MachineToApplication;
42                 bool allow_location, allow_override;
43                 bool inherit_on_child_apps;
44                 bool restart_on_external_changes;
45                 bool require_permission;
46
47                 string config_source = String.Empty;
48                 bool force_update;
49                 string name, type_name;
50                 string raw_xml;
51                 
52                 ProtectedConfigurationProvider protection_provider;
53                 
54
55                 [MonoTODO ("default value for require_permission")]
56                 internal SectionInformation ()
57                 {
58                         allow_definition = ConfigurationAllowDefinition.Everywhere;
59                         allow_location = true;
60                         allow_override = true;
61                         inherit_on_child_apps = true;
62                         restart_on_external_changes = true;
63                 }
64
65                 internal string ConfigFilePath {
66                         get;
67                         set;
68                 }
69                 
70                 public ConfigurationAllowDefinition AllowDefinition {
71                         get { return allow_definition; }
72                         set { allow_definition = value; }
73                 }
74
75                 public ConfigurationAllowExeDefinition AllowExeDefinition {
76                         get { return allow_exe_definition; }
77                         set { allow_exe_definition = value; }
78                 }
79
80                 public bool AllowLocation {
81                         get { return allow_location; }
82                         set { allow_location = value; }
83                 }
84
85                 public bool AllowOverride {
86                         get { return allow_override; }
87                         set { allow_override = value; }
88                 }
89
90                 public string ConfigSource {
91                         get { return config_source; }
92                         set {
93                                 if (value == null)
94                                         value = String.Empty;
95
96                                 config_source = value; 
97                         }
98                 }
99
100                 public bool ForceSave {
101                         get { return force_update; }
102                         set { force_update = value; }
103                 }
104
105                 public bool InheritInChildApplications {
106                         get { return inherit_on_child_apps; }
107                         set { inherit_on_child_apps = value; }
108                 }
109
110                 [MonoTODO]
111                 public bool IsDeclarationRequired {
112                         get { throw new NotImplementedException (); }
113                 }
114
115                 [MonoTODO]
116                 public bool IsDeclared {
117                         get { return false; }
118                 }
119
120                 [MonoTODO]
121                 public bool IsLocked {
122                         get { return false; }
123                 }
124
125                 public bool IsProtected {
126                         get { return protection_provider != null; }
127                 }
128
129                 public string Name {
130                         get { return name; }
131                 }
132
133                 public ProtectedConfigurationProvider ProtectionProvider {
134                         get { return protection_provider; }
135                 }
136
137                 [MonoTODO]
138                 public bool RequirePermission {
139                         get { return require_permission; }
140                         set { require_permission = value; }
141                 }
142
143                 [MonoTODO]
144                 public bool RestartOnExternalChanges {
145                         get { return restart_on_external_changes; }
146                         set { restart_on_external_changes = value; }
147                 }
148
149                 [MonoTODO]
150                 public string SectionName {
151                         get { return name; }
152                 }
153
154                 public string Type {
155                         get { return type_name; }
156                         set {
157                                 if (value == null || value.Length == 0)
158                                         throw new ArgumentException ("Value cannot be null or empty.");
159
160                                 type_name = value; 
161                         }
162                 }
163
164                 public ConfigurationSection GetParentSection ()
165                 {
166                         return parent;
167                 }
168
169                 internal void SetParentSection (ConfigurationSection parent)
170                 {
171                         this.parent = parent;
172                 }
173
174                 public string GetRawXml ()
175                 {
176                         return raw_xml;
177                 }
178
179                 public void ProtectSection (string provider)
180                 {
181                         protection_provider = ProtectedConfiguration.GetProvider (provider, true);
182                 }
183
184                 [MonoTODO]
185                 public void ForceDeclaration (bool require)
186                 {
187                 }
188
189                 public void ForceDeclaration ()
190                 {
191                         ForceDeclaration (true);
192                 }
193
194                 [MonoTODO]
195                 public void RevertToParent ()
196                 {
197                         throw new NotImplementedException ();
198                 }
199
200                 public void UnprotectSection ()
201                 {
202                         protection_provider = null;
203                 }
204
205                 public void SetRawXml (string xml)
206                 {
207                         raw_xml = xml;
208                 }
209
210                 [MonoTODO]
211                 internal void SetName (string name)
212                 {
213                         this.name = name;
214                 }
215         }
216 }
217 #endif