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 using System.Collections; 31 using System.Xml; 32 33 namespace System.Configuration 34 { 35 public sealed class SectionInformation 36 { 37 ConfigurationSection parent; 38 39 ConfigurationAllowDefinition allow_definition = ConfigurationAllowDefinition.Everywhere; 40 ConfigurationAllowExeDefinition allow_exe_definition = ConfigurationAllowExeDefinition.MachineToApplication; 41 bool allow_location, allow_override; 42 bool inherit_on_child_apps; 43 bool restart_on_external_changes; 44 bool require_permission; 45 46 string config_source = String.Empty; 47 bool force_update; 48 string name, type_name; 49 string raw_xml; 50 51 ProtectedConfigurationProvider protection_provider; 52 53 54 [MonoTODO ("default value for require_permission")] SectionInformation()55 internal SectionInformation () 56 { 57 allow_definition = ConfigurationAllowDefinition.Everywhere; 58 allow_location = true; 59 allow_override = true; 60 inherit_on_child_apps = true; 61 restart_on_external_changes = true; 62 } 63 64 internal string ConfigFilePath { 65 get; 66 set; 67 } 68 69 public ConfigurationAllowDefinition AllowDefinition { 70 get { return allow_definition; } 71 set { allow_definition = value; } 72 } 73 74 public ConfigurationAllowExeDefinition AllowExeDefinition { 75 get { return allow_exe_definition; } 76 set { allow_exe_definition = value; } 77 } 78 79 public bool AllowLocation { 80 get { return allow_location; } 81 set { allow_location = value; } 82 } 83 84 public bool AllowOverride { 85 get { return allow_override; } 86 set { allow_override = value; } 87 } 88 89 public string ConfigSource { 90 get { return config_source; } 91 set { 92 if (value == null) 93 value = String.Empty; 94 95 config_source = value; 96 } 97 } 98 99 public bool ForceSave { 100 get { return force_update; } 101 set { force_update = value; } 102 } 103 104 public bool InheritInChildApplications { 105 get { return inherit_on_child_apps; } 106 set { inherit_on_child_apps = value; } 107 } 108 109 [MonoTODO] 110 public bool IsDeclarationRequired { 111 get { throw new NotImplementedException (); } 112 } 113 114 [MonoTODO] 115 public bool IsDeclared { 116 get { return false; } 117 } 118 119 [MonoTODO] 120 public bool IsLocked { 121 get { return false; } 122 } 123 124 public bool IsProtected { 125 get { return protection_provider != null; } 126 } 127 128 public string Name { 129 get { return name; } 130 } 131 132 public ProtectedConfigurationProvider ProtectionProvider { 133 get { return protection_provider; } 134 } 135 136 [MonoTODO] 137 public bool RequirePermission { 138 get { return require_permission; } 139 set { require_permission = value; } 140 } 141 142 [MonoTODO] 143 public bool RestartOnExternalChanges { 144 get { return restart_on_external_changes; } 145 set { restart_on_external_changes = value; } 146 } 147 148 [MonoTODO] 149 public string SectionName { 150 get { return name; } 151 } 152 153 public string Type { 154 get { return type_name; } 155 set { 156 if (value == null || value.Length == 0) 157 throw new ArgumentException ("Value cannot be null or empty."); 158 159 type_name = value; 160 } 161 } 162 GetParentSection()163 public ConfigurationSection GetParentSection () 164 { 165 return parent; 166 } 167 SetParentSection(ConfigurationSection parent)168 internal void SetParentSection (ConfigurationSection parent) 169 { 170 this.parent = parent; 171 } 172 GetRawXml()173 public string GetRawXml () 174 { 175 return raw_xml; 176 } 177 ProtectSection(string protectionProvider)178 public void ProtectSection (string protectionProvider) 179 { 180 protection_provider = ProtectedConfiguration.GetProvider (protectionProvider, true); 181 } 182 183 [MonoTODO] ForceDeclaration(bool force)184 public void ForceDeclaration (bool force) 185 { 186 } 187 ForceDeclaration()188 public void ForceDeclaration () 189 { 190 ForceDeclaration (true); 191 } 192 193 [MonoTODO] RevertToParent()194 public void RevertToParent () 195 { 196 throw new NotImplementedException (); 197 } 198 UnprotectSection()199 public void UnprotectSection () 200 { 201 protection_provider = null; 202 } 203 SetRawXml(string rawXml)204 public void SetRawXml (string rawXml) 205 { 206 raw_xml = rawXml; 207 } 208 209 [MonoTODO] SetName(string name)210 internal void SetName (string name) 211 { 212 this.name = name; 213 } 214 } 215 } 216 217