implement for v2
authorBen Maurer <benm@mono-cvs.ximian.com>
Fri, 7 Nov 2003 22:40:02 +0000 (22:40 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Fri, 7 Nov 2003 22:40:02 +0000 (22:40 -0000)
svn path=/trunk/mcs/; revision=19723

mcs/class/System/System.Configuration.Provider/ChangeLog [new file with mode: 0644]
mcs/class/System/System.Configuration.Provider/IProvider.cs [new file with mode: 0644]
mcs/class/System/System.Configuration.Provider/NotSupportedByProviderException.cs [new file with mode: 0644]
mcs/class/System/System.Configuration.Provider/ProviderCollection.cs [new file with mode: 0644]

diff --git a/mcs/class/System/System.Configuration.Provider/ChangeLog b/mcs/class/System/System.Configuration.Provider/ChangeLog
new file mode 100644 (file)
index 0000000..74bd46a
--- /dev/null
@@ -0,0 +1,4 @@
+2003-11-07 Ben Maurer  <bmaurer@users.sourceforge.net>
+
+       * Implemented everything for V2.
+
diff --git a/mcs/class/System/System.Configuration.Provider/IProvider.cs b/mcs/class/System/System.Configuration.Provider/IProvider.cs
new file mode 100644 (file)
index 0000000..d6e1993
--- /dev/null
@@ -0,0 +1,20 @@
+//
+// System.Configuration.Provider.IProvider
+//
+// Authors:
+//     Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace System.Configuration.Provider {
+       public interface IProvider {
+               void Initialize (string name, NameValueCollection config);
+               string Name { get; }
+       }
+}
+#endif
diff --git a/mcs/class/System/System.Configuration.Provider/NotSupportedByProviderException.cs b/mcs/class/System/System.Configuration.Provider/NotSupportedByProviderException.cs
new file mode 100644 (file)
index 0000000..21b8a1c
--- /dev/null
@@ -0,0 +1,22 @@
+//
+// System.Configuration.Provider.NotSupportedByProviderException
+//
+// Authors:
+//     Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Runtime.Serialization;
+
+namespace System.Configuration.Provider {
+       [Serializable]
+       public class NotSupportedByProviderException : Exception {
+               public NotSupportedByProviderException () : base () {}
+               protected NotSupportedByProviderException (SerializationInfo info, StreamingContext context)  : base (info, context) {}
+               public NotSupportedByProviderException (string message) : base (message) {}
+               public NotSupportedByProviderException (string message, Exception innerException)  : base (message, innerException) {}
+       }
+}
+#endif
\ No newline at end of file
diff --git a/mcs/class/System/System.Configuration.Provider/ProviderCollection.cs b/mcs/class/System/System.Configuration.Provider/ProviderCollection.cs
new file mode 100644 (file)
index 0000000..b88a7eb
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// System.Configuration.Provider.ProviderCollection
+//
+// Authors:
+//     Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+
+namespace System.Configuration.Provider {
+       public class ProviderCollection : ICollection
+       {
+               public ProviderCollection ()
+               {
+                       lookup = new Hashtable (10, CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
+                       values = new ArrayList ();
+               }
+       
+               public virtual void Add (IProvider provider)
+               {
+                       if (readOnly)
+                               throw new NotSupportedException ();
+                       
+                       if (provider == null || provider.Name == null)
+                               throw new ArgumentNullException ();
+                       
+                       int pos = values.Add (provider);
+                       try {
+                               lookup.Add (provider.Name, pos);
+                       } catch {
+                               values.RemoveAt (pos);
+                               throw;
+                       }
+               }
+               
+               public void Clear ()
+               {
+                       if (readOnly)
+                               throw new NotSupportedException ();
+                       values.Clear ();
+                       lookup.Clear ();
+               }
+                               
+               public void CopyTo (Array array, int index)
+               {
+                       values.CopyTo (array, index);
+               }
+               
+               public IEnumerator GetEnumerator ()
+               {
+                       return values.GetEnumerator();
+               }
+               
+               public void Remove (string name)
+               {
+                       if (readOnly)
+                               throw new NotSupportedException ();
+                       
+                       object position = lookup [name];
+                       
+                       if (position == null || !(position is int))
+                               throw new ArgumentException ();
+                       
+                       int pos = (int) position;
+                       if (pos >= values.Count)
+                               throw new ArgumentException ();
+                       
+                       values.RemoveAt (pos);
+                       lookup.Remove (name);
+                       
+                       ArrayList changed = new ArrayList ();
+                       foreach (DictionaryEntry de in lookup) {
+                                       if ((int) de.Value <= pos)
+                                               continue;
+                                       changed.Add (de.Key);
+                       }
+                       
+                       foreach (string key in changed)
+                               lookup [key] = (int)lookup [key] - 1;
+               }
+               
+               public void SetReadOnly ()
+               {
+                       readOnly = true;
+               }
+               
+               public int Count { get { return values.Count; } }
+               public bool IsSynchronized { get { return false; } }
+               public object SyncRoot { get { return this; } }
+               
+               public IProvider this [string name] { 
+                       get {
+                               object pos = lookup [name];
+                               if (pos == null) return null;
+                               
+                               return values [(int) pos] as IProvider;
+                       }
+               }
+               
+               
+               Hashtable lookup;
+               bool readOnly;
+               ArrayList values;
+        
+       }
+}
+#endif