2 // System.Data.DataTableCollection.cs
5 // Christopher Podurgiel (cpodurgiel@msn.com)
15 /// Represents the collection of tables for the DataSet.
17 public class DataTableCollection : InternalDataCollectionBase
19 private DataTable[] tables = null;
22 public virtual DataTable Add () {
23 DataTable table = new DataTable ();
24 DataTable[] tmp = new DataTable[size + 1];
27 Array.Copy (tables, tmp, size);
30 tables[size - 1] = table;
35 public virtual void Add (DataTable table) {
36 DataTable[] tmp = new DataTable[size + 1];
38 Array.Copy (tables, tmp, size);
41 tables[size - 1] = table;
44 public virtual DataTable Add (string name) {
45 DataTable table = this.Add ();
46 table.TableName = name;
51 public void AddRange (DataTable[] tables_to_add) {
52 for (int i = 0; i < tables_to_add.Length; i++) {
53 this.Add (tables_to_add[i]);
59 public bool CanRemove (DataTable table) {
60 throw new NotImplementedException ();
63 public void Clear () {
64 /* FIXME: is this correct? */
69 public bool Contains (string name) {
70 for (int i = 0; i < size; i++) {
71 if (tables[i].TableName == name)
78 public void CopyTo (Array ar, int index) {
79 Array.Copy (tables, ar, size);
82 public virtual int IndexOf (DataTable table) {
83 for (int i = 0; i < size; i++) {
84 if (tables[i] == table)
91 public virtual int IndexOf (string name) {
92 for (int i = 0; i < size; i++) {
93 if (tables[i].TableName == name)
100 public void Remove (DataTable table) {
101 this.RemoveAt (this.IndexOf (table));
104 public void Remove (string name) {
105 this.RemoveAt (this.IndexOf (name));
109 public void RemoveAt (int index) {
110 throw new NotImplementedException ();
113 public override int Count {
117 // IsReadOnly and IsSynchronized must be implemented or
118 // is it safe to use InternalDataCollectionBase's
120 public DataTable this[int index] {
123 return tables[index];
128 public DataTable this[string name] {
130 for (int i = 0; i < size; i++) {
131 if (tables[i].TableName == name)
140 protected override ArrayList List {
141 throw new NotImplementedException ();
145 public event CollectionChangeEventHandler CollectionChanged;
148 public event CollectionChangeEventHandler CollectionChanging;
151 protected virtual void OnCollectionChanged (
152 CollectionChangeEventArgs ccevent) {
156 protected internal virtual void OnCollectionChanging (
157 CollectionChangeEventArgs ccevent) {