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)
35 using System.Collections.Specialized;
37 namespace System.Configuration
39 public sealed class ProviderSettings: ConfigurationElement
41 ConfigNameValueCollection parameters;
43 static ConfigurationProperty nameProp;
44 static ConfigurationProperty typeProp;
45 static ConfigurationPropertyCollection properties;
47 static ProviderSettings ()
49 nameProp = new ConfigurationProperty ("name", typeof (string), null, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
50 typeProp = new ConfigurationProperty ("type", typeof (string), null, ConfigurationPropertyOptions.IsRequired);
51 properties = new ConfigurationPropertyCollection ();
53 properties.Add (nameProp);
54 properties.Add (typeProp);
57 public ProviderSettings ()
61 public ProviderSettings (string name, string type)
67 protected override bool OnDeserializeUnrecognizedAttribute (string name, string value)
69 if (parameters == null)
70 parameters = new ConfigNameValueCollection ();
71 parameters [name] = value;
72 parameters.ResetModified ();
76 protected internal override bool IsModified ()
78 return (parameters != null && parameters.IsModified) || base.IsModified ();
81 protected internal override void Reset (ConfigurationElement parentElement)
83 base.Reset (parentElement);
85 ProviderSettings sec = parentElement as ProviderSettings;
86 if (sec != null && sec.parameters != null)
87 parameters = new ConfigNameValueCollection (sec.parameters);
93 protected internal override void Unmerge (
94 ConfigurationElement source, ConfigurationElement parent,
95 ConfigurationSaveMode updateMode)
97 base.Unmerge (source, parent, updateMode);
100 [ConfigurationProperty ("name", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
102 get { return (string) this [nameProp]; }
103 set { this [nameProp] = value; }
106 [ConfigurationProperty ("type", Options = ConfigurationPropertyOptions.IsRequired)]
108 get { return (string) this [typeProp]; }
109 set { this [typeProp] = value; }
112 protected internal override ConfigurationPropertyCollection Properties {
113 get { return properties; }
116 public NameValueCollection Parameters {
118 if (parameters == null)
119 parameters = new ConfigNameValueCollection ();