Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DataTableCollection.cs « System.Data « System.Data « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 646f10f7d4d49f14a1bcb97fe92b2d408f81d7ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//
// System.Data.DataTableCollection.cs
//
// Authors:
//   Christopher Podurgiel (cpodurgiel@msn.com)
//   Tim Coleman <tim@timcoleman.com>
//
// (C) Chris Podurgiel
// (C) Copyright 2002 Tim Coleman
//

using System;
using System.Collections;
using System.ComponentModel;

namespace System.Data
{
	/// <summary>
	/// Represents the collection of tables for the DataSet.
	/// </summary>
	public class DataTableCollection : InternalDataCollectionBase
	{
		DataSet dataSet;
		const string defaultTableName = "Table1";
		Hashtable tables;

		#region Constructors 

		// LAMESPEC: This constructor is undocumented
		protected internal DataTableCollection (DataSet dataSet)
			: base ()
		{
			this.dataSet = dataSet;
			this.tables = new Hashtable ();
		}
		
		#endregion
		
		#region Properties

		public override int Count {
			get { return list.Count; }
		}

		public DataTable this[int index] {
			get { return (DataTable)(list[index]); }
		}

		public DataTable this[string name] {
			get { return (DataTable)(tables[name]); }
		}

		protected override ArrayList List {
			get { return list; }
		}

		#endregion
	
		#region Methods	

		public virtual DataTable Add () 
		{
			return this.Add (defaultTableName);
		}

		public virtual void Add (DataTable table) 
		{
			list.Add (table);
			table.dataSet = dataSet;
			tables[table.TableName] = table;
		}

		public virtual DataTable Add (string name) 
		{
			DataTable table = new DataTable (name);
			this.Add (table);
			return table;
		}

		public void AddRange (DataTable[] tables) 
		{
			foreach (DataTable table in tables)
				this.Add (table);
		}

		[MonoTODO]
		public bool CanRemove (DataTable table) 
		{
			throw new NotImplementedException ();
		}

		public void Clear () 
		{
			list.Clear ();
			tables.Clear ();
		}

		public bool Contains (string name) 
		{
			return tables.Contains (name);
		}

		public virtual int IndexOf (DataTable table) 
		{
			return list.IndexOf (table);
		}

		public virtual int IndexOf (string name) 
		{
			return list.IndexOf (tables[name]);
		}

		public void Remove (DataTable table) 
		{
			this.Remove (table.TableName);
		}

		public void Remove (string name) 
		{
			list.Remove (tables[name]);
			tables.Remove (name);
		}

		public void RemoveAt (int index) 
		{
			tables.Remove (((DataTable)(list[index])).TableName);
			list.RemoveAt (index);
		}

		#endregion

		#region Events
		
		public event CollectionChangeEventHandler CollectionChanged;
		public event CollectionChangeEventHandler CollectionChanging;

		#endregion
	}
}