2005-09-23 Chris Toshok <toshok@ximian.com>
[mono.git] / mcs / class / System.Configuration / System.Configuration / ProviderSettings.cs
1 //
2 // System.Configuration.ProviderSettings.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
32 using System;
33 using System.Xml;
34 using System.Collections.Specialized;
35
36 namespace System.Configuration
37 {
38         public sealed class ProviderSettings: ConfigurationElement
39         {
40                 ConfigNameValueCollection parameters;
41                 
42                 public ProviderSettings ()
43                 {
44                 }
45                 
46                 public ProviderSettings (string name, string type)
47                 {
48                         Name = name;
49                         Type = type;
50                 }
51                 
52                 protected override bool OnDeserializeUnrecognizedAttribute (string name, string value)
53                 {
54                         if (parameters == null)
55                                 parameters = new ConfigNameValueCollection ();
56                         parameters [name] = value;
57                         parameters.ResetModified ();
58                         return true;
59                 }
60
61                 protected internal override bool IsModified ()
62                 {
63                         return (parameters != null && parameters.IsModified) || base.IsModified ();
64                 }
65
66                 protected internal override void Reset (ConfigurationElement parentElement)
67                 {
68                         base.Reset (parentElement);
69
70                         ProviderSettings sec = parentElement as ProviderSettings;
71                         if (sec != null && sec.parameters != null)
72                                 parameters = new ConfigNameValueCollection (sec.parameters);
73                         else
74                                 parameters = null;
75                 }
76
77                 [MonoTODO]
78                 protected internal override void Unmerge (
79                                 ConfigurationElement source, ConfigurationElement parent,
80                                 bool serializeCollectionKey, ConfigurationSaveMode updateMode)
81                 {
82                         base.Unmerge (source, parent, serializeCollectionKey, updateMode);
83                 }
84                 
85                 [ConfigurationProperty ("name", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
86                 public string Name {
87                         get { return (string) this ["name"]; }
88                         set { this ["name"] = value; }
89                 }
90                 
91                 [ConfigurationProperty ("type", Options = ConfigurationPropertyOptions.IsRequired)]
92                 public string Type {
93                         get { return (string) this ["type"]; }
94                         set { this ["type"] = value; }
95                 }
96                 
97                 public NameValueCollection Parameters {
98                         get {
99                                 if (parameters == null)
100                                         parameters = new ConfigNameValueCollection ();
101                                 return parameters;
102                         }
103                 }
104         }
105 }
106
107 #endif