* DataTableCollection.cs: Sequester NET_2_0 and NET_1_1 specific code into separate...
authorRaja R Harinath <harinath@hurrynot.org>
Mon, 5 Jan 2009 07:30:49 +0000 (07:30 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Mon, 5 Jan 2009 07:30:49 +0000 (07:30 -0000)
svn path=/trunk/mcs/; revision=122409

mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataTableCollection.cs

index eca412332fffa248f6991bda3fe9f12c31389d32..a738ae8213b882d78789eacd8bb58d9c01656742 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-04  Raja R Harinath  <harinath@hurrynot.org>
+
+       * DataTableCollection.cs: Sequester NET_2_0 and NET_1_1 specific
+       code into separate parts.
+
 2009-01-02  Ivan N. Zlatev  <contact@i-nz.net>
 
        * DataViewManager.cs: Implement all MonoTODO. Fixes the WinForms 
index 0e14ec5c404bf6a43d1792addbbb796d933274d1..b835978f900f45f5f395ec74419705655a22a159 100644 (file)
@@ -46,14 +46,7 @@ namespace System.Data
                 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
        [DefaultEvent ("CollectionChanged")]
        [ListBindable (false)]
-#if !NET_2_0
-       [Serializable]
-#endif
-       public
-#if NET_2_0
-       sealed
-#endif
-       class DataTableCollection : InternalDataCollectionBase {
+       public partial class DataTableCollection : InternalDataCollectionBase {
                DataSet dataSet;
                DataTable[] mostRecentTables;
 
@@ -84,15 +77,6 @@ namespace System.Data
                        }
                }
 
-#if NET_2_0
-               public DataTable this [string name, string tbNamespace] {
-                       get {
-                               int index = IndexOf (name, tbNamespace, true);
-                               return index < 0 ? null : (DataTable) List [index];
-                       }
-               }
-#endif
-
                protected override ArrayList List {
                        get { return base.List; }
                }
@@ -165,15 +149,6 @@ namespace System.Data
                        return table;
                }
 
-#if NET_2_0
-               public DataTable Add (string name, string tbNamespace)
-               {
-                       DataTable table = new DataTable (name, tbNamespace);
-                       this.Add (table);
-                       return table;
-               }
-#endif
-
                public void AddRange (DataTable [] tables)
                {
                        if (dataSet != null && dataSet.InitInProgress) {
@@ -219,18 +194,6 @@ namespace System.Data
                        return (-1 != IndexOf (name, false));
                }
 
-#if NET_2_0
-               public bool Contains (string name, string tableNamespace)
-               {
-                       return (IndexOf (name, tableNamespace) != -1);
-               }
-
-               public void CopyTo (DataTable [] array, int index)
-               {
-                       CopyTo ((Array) array, index);
-               }
-#endif
-
                public
 #if !NET_2_0
                virtual
@@ -249,16 +212,6 @@ namespace System.Data
                        return IndexOf (tableName, false);
                }
 
-#if NET_2_0
-               public int IndexOf (string tableName, string tableNamespace)
-               {
-                       if (tableNamespace == null)
-                               throw new ArgumentNullException ("'tableNamespace' argument cannot be null.",
-                                               "tableNamespace");
-                       return IndexOf (tableName, tableNamespace, false);
-               }
-#endif
-
                public void Remove (DataTable table)
                {
                        OnCollectionChanging (new CollectionChangeEventArgs (CollectionChangeAction.Remove, table));
@@ -278,17 +231,6 @@ namespace System.Data
                        RemoveAt (index);
                }
 
-#if NET_2_0
-               public void Remove (string name, string tableNamespace)
-               {
-                       int index = IndexOf (name, tableNamespace, true);
-                       if (index == -1)
-                                throw new ArgumentException ("Table " + name + " does not belong to this DataSet");
-
-                       RemoveAt (index);
-               }
-#endif
-
                public void RemoveAt (int index)
                {
                        Remove (this [index]);
@@ -323,45 +265,6 @@ namespace System.Data
                #endregion
 
                #region Private methods
-#if NET_2_0
-               private int IndexOf (string name, string ns, bool error)
-               {
-                       int index = -1, count = 0, match = -1;
-                       do {
-                               index = IndexOf (name, error, index+1);
-
-                               if (index == -1)
-                                       break;
-
-                               if (ns == null) {
-                                       if (count > 1)
-                                               break;
-                                       count++;
-                                       match = index;
-                               } else if (this [index].Namespace.Equals (ns))
-                                       return index;
-
-                       } while (index != -1 && index < Count);
-
-                       if (count == 1)
-                               return match;
-
-                       if (count == 0 || !error)
-                               return -1;
-
-                       throw new ArgumentException ("The given name '" + name + "' matches atleast two names" +
-                                       "in the collection object with different namespaces");
-               }
-#endif
-
-               private int IndexOf (string name, bool error)
-               {
-#if NET_2_0
-                       return IndexOf (name, null, error);
-# else
-                       return IndexOf (name, error, 0);
-#endif
-               }
 
                private int IndexOf (string name, bool error, int start)
                {
@@ -463,4 +366,91 @@ namespace System.Data
 
                #endregion
        }
+
+#if NET_2_0
+       sealed partial class DataTableCollection {
+               public DataTable this [string name, string tbNamespace] {
+                       get {
+                               int index = IndexOf (name, tbNamespace, true);
+                               return index < 0 ? null : (DataTable) List [index];
+                       }
+               }
+
+               public DataTable Add (string name, string tbNamespace)
+               {
+                       DataTable table = new DataTable (name, tbNamespace);
+                       this.Add (table);
+                       return table;
+               }
+
+               public bool Contains (string name, string tableNamespace)
+               {
+                       return (IndexOf (name, tableNamespace) != -1);
+               }
+
+               public int IndexOf (string tableName, string tableNamespace)
+               {
+                       if (tableNamespace == null)
+                               throw new ArgumentNullException ("'tableNamespace' argument cannot be null.",
+                                               "tableNamespace");
+                       return IndexOf (tableName, tableNamespace, false);
+               }
+
+               public void Remove (string name, string tableNamespace)
+               {
+                       int index = IndexOf (name, tableNamespace, true);
+                       if (index == -1)
+                                throw new ArgumentException ("Table " + name + " does not belong to this DataSet");
+
+                       RemoveAt (index);
+               }
+
+               private int IndexOf (string name, string ns, bool error)
+               {
+                       int index = -1, count = 0, match = -1;
+                       do {
+                               index = IndexOf (name, error, index+1);
+
+                               if (index == -1)
+                                       break;
+
+                               if (ns == null) {
+                                       if (count > 1)
+                                               break;
+                                       count++;
+                                       match = index;
+                               } else if (this [index].Namespace.Equals (ns))
+                                       return index;
+
+                       } while (index != -1 && index < Count);
+
+                       if (count == 1)
+                               return match;
+
+                       if (count == 0 || !error)
+                               return -1;
+
+                       throw new ArgumentException ("The given name '" + name + "' matches atleast two names" +
+                                       "in the collection object with different namespaces");
+               }
+
+               private int IndexOf (string name, bool error)
+               {
+                       return IndexOf (name, null, error);
+               }
+
+               public void CopyTo (DataTable [] array, int index)
+               {
+                       CopyTo ((Array) array, index);
+               }
+       }
+#else
+       [Serializable]
+       partial class DataTableCollection {
+               private int IndexOf (string name, bool error)
+               {
+                       return IndexOf (name, error, 0);
+               }
+       }
+#endif
 }