"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;
}
}
-#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; }
}
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) {
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
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));
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]);
#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)
{
#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
}