2 // System.Configuration.ProviderSettings.cs
5 // Duncan Mak (duncan@ximian.com)
6 // Lluis Sanchez Gual (lluis@novell.com)
7 // Chris Toshok (toshok@ximian.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 // Copyright (C) 2004,2005 Novell, Inc (http://www.novell.com)
33 using System.Collections.Specialized;
35 namespace System.Configuration
37 public sealed class ProviderSettings: ConfigurationElement
39 ConfigNameValueCollection parameters;
41 static ConfigurationProperty nameProp;
42 static ConfigurationProperty typeProp;
43 static ConfigurationPropertyCollection properties;
45 static ProviderSettings ()
47 nameProp = new ConfigurationProperty ("name", typeof (string), null, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
48 typeProp = new ConfigurationProperty ("type", typeof (string), null, ConfigurationPropertyOptions.IsRequired);
49 properties = new ConfigurationPropertyCollection ();
51 properties.Add (nameProp);
52 properties.Add (typeProp);
55 public ProviderSettings ()
59 public ProviderSettings (string name, string type)
65 protected override bool OnDeserializeUnrecognizedAttribute (string name, string value)
67 if (parameters == null)
68 parameters = new ConfigNameValueCollection ();
69 parameters [name] = value;
70 parameters.ResetModified ();
74 protected internal override bool IsModified ()
76 return (parameters != null && parameters.IsModified) || base.IsModified ();
79 protected internal override void Reset (ConfigurationElement parentElement)
81 base.Reset (parentElement);
83 ProviderSettings sec = parentElement as ProviderSettings;
84 if (sec != null && sec.parameters != null)
85 parameters = new ConfigNameValueCollection (sec.parameters);
91 protected internal override void Unmerge (
92 ConfigurationElement source, ConfigurationElement parent,
93 ConfigurationSaveMode updateMode)
95 base.Unmerge (source, parent, updateMode);
98 [ConfigurationProperty ("name", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
100 get { return (string) this [nameProp]; }
101 set { this [nameProp] = value; }
104 [ConfigurationProperty ("type", Options = ConfigurationPropertyOptions.IsRequired)]
106 get { return (string) this [typeProp]; }
107 set { this [typeProp] = value; }
110 protected internal override ConfigurationPropertyCollection Properties {
111 get { return properties; }
114 public NameValueCollection Parameters {
116 if (parameters == null)
117 parameters = new ConfigNameValueCollection ();