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];
41 Array.Copy (tables, tmp, size);
44 tables[size - 1] = table;
47 public virtual DataTable Add (string name) {
48 DataTable table = this.Add ();
49 table.TableName = name;
54 public void AddRange (DataTable[] tables_to_add) {
55 for (int i = 0; i < tables_to_add.Length; i++) {
56 this.Add (tables_to_add[i]);
61 public bool CanRemove (DataTable table) {
62 throw new NotImplementedException ();
65 public void Clear () {
66 /* FIXME: is this correct? */
71 public bool Contains (string name) {
72 for (int i = 0; i < size; i++) {
73 if (tables[i].TableName == name)
80 public virtual int IndexOf (DataTable table) {
81 for (int i = 0; i < size; i++) {
82 if (tables[i] == table)
89 public virtual int IndexOf (string name) {
90 for (int i = 0; i < size; i++) {
91 if (tables[i].TableName == name)
98 public void Remove (DataTable table) {
99 this.RemoveAt (this.IndexOf (table));
102 public void Remove (string name) {
103 this.RemoveAt (this.IndexOf (name));
107 public void RemoveAt (int index) {
108 throw new NotImplementedException ();
111 public override int Count {
115 // IsReadOnly and IsSynchronized must be implemented or
116 // is it safe to use InternalDataCollectionBase's
118 public DataTable this[int index] {
121 return tables[index];
126 public DataTable this[string name] {
128 for (int i = 0; i < size; i++) {
129 if (tables[i].TableName == name)
137 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 ();