2 // System.Data.DataTableCollection.cs
5 // Christopher Podurgiel (cpodurgiel@msn.com)
11 using System.Collections;
12 using System.ComponentModel;
17 /// Represents the collection of tables for the DataSet.
19 public class DataTableCollection : InternalDataCollectionBase
21 private DataTable[] tables = null;
24 public virtual DataTable Add () {
25 DataTable table = new DataTable ();
26 DataTable[] tmp = new DataTable[size + 1];
29 Array.Copy (tables, tmp, size);
32 tables[size - 1] = table;
37 public virtual void Add (DataTable table) {
38 DataTable[] tmp = new DataTable[size + 1];
40 Array.Copy (tables, tmp, size);
43 tables[size - 1] = table;
46 public virtual DataTable Add (string name) {
47 DataTable table = this.Add ();
48 table.TableName = name;
53 public void AddRange (DataTable[] tables_to_add) {
54 for (int i = 0; i < tables_to_add.Length; i++) {
55 this.Add (tables_to_add[i]);
60 public bool CanRemove (DataTable table) {
61 throw new NotImplementedException ();
64 public void Clear () {
65 /* FIXME: is this correct? */
70 public bool Contains (string name) {
71 for (int i = 0; i < size; i++) {
72 if (tables[i].TableName == name)
79 public virtual int IndexOf (DataTable table) {
80 for (int i = 0; i < size; i++) {
81 if (tables[i] == table)
88 public virtual int IndexOf (string name) {
89 for (int i = 0; i < size; i++) {
90 if (tables[i].TableName == name)
97 public void Remove (DataTable table) {
98 this.RemoveAt (this.IndexOf (table));
101 public void Remove (string name) {
102 this.RemoveAt (this.IndexOf (name));
106 public void RemoveAt (int index) {
107 throw new NotImplementedException ();
110 public override int Count {
114 // IsReadOnly and IsSynchronized must be implemented or
115 // is it safe to use InternalDataCollectionBase's
117 public DataTable this[int index] {
120 return tables[index];
125 public DataTable this[string name] {
127 for (int i = 0; i < size; i++) {
128 if (tables[i].TableName == name)
136 protected override ArrayList List {
139 throw new NotImplementedException ();
143 public event CollectionChangeEventHandler CollectionChanged;
145 public event CollectionChangeEventHandler CollectionChanging;
147 protected virtual void OnCollectionChanged (
148 CollectionChangeEventArgs ccevent) {
150 throw new NotImplementedException ();
153 protected internal virtual void OnCollectionChanging (
154 CollectionChangeEventArgs ccevent) {
156 throw new NotImplementedException ();