2004-03-10 Umadevi S (sumadevi@novell.com)
[mono.git] / mcs / class / System.Data / System.Data / InternalDataCollectionBase.cs
1 //
2 // System.Data.InternalDataCollectionBase.cs
3 //
4 // Base class for:
5 //     DataRowCollection
6 //     DataColumnCollection
7 //     DataTableCollection
8 //     DataRelationCollection
9 //     DataConstraintCollection
10 //
11 // Author:
12 //   Daniel Morgan <danmorg@sc.rr.com>
13 //   Tim Coleman <tim@timcoleman.com>
14 //
15 // (C) Copyright 2002 Daniel Morgan
16 // (C) Copyright 2002 Tim Coleman
17 //
18
19 using System;
20 using System.Collections;
21 using System.ComponentModel;
22
23 namespace System.Data
24 {
25         /// <summary>
26         /// Base class for System.Data collection classes 
27         /// that are used within a DataTable object
28         /// to represent a collection of 
29         /// relations, tables, rows, columns, and constraints
30         /// </summary>
31
32         public class InternalDataCollectionBase : ICollection, IEnumerable 
33         {
34                 #region Fields
35
36                 // FIXME: keep list protected until mcs/mono is fixed
37                 protected ArrayList list = null;
38                 private bool readOnly = false;
39                 private bool synchronized = false; 
40
41                 #endregion
42
43                 #region Constructors
44
45                 public InternalDataCollectionBase() 
46                 {
47                         list = new ArrayList();
48                 }
49
50                 #endregion
51
52                 #region Properties
53         
54                 /// <summary>
55                 /// Gets the total number of elements in a collection.
56                 /// </summary>
57                 [Browsable (false)]
58                 public virtual int Count {
59                         get { return list.Count; }
60                 }
61
62                 /// <summary>
63                 /// Gets a value indicating whether the InternalDataCollectionBase is read-only.
64                 /// </summary>
65                 [Browsable (false)]
66                 public bool IsReadOnly {
67                         get { return readOnly; }
68                 }
69
70                 /// <summary>
71                 /// Gets a value indicating whether the InternalDataCollectionBase is synchronized.
72                 /// </summary>
73                 [Browsable (false)]
74                 public bool IsSynchronized {
75                         get { return synchronized; }
76                 }
77
78                 /// <summary>
79                 /// Gets the items of the collection as a list.
80                 /// </summary>
81                 protected virtual ArrayList List {
82                         get { return list; }
83                 }
84
85                 /// <summary>
86                 /// Gets an object that can be used to synchronize the collection.
87                 /// </summary>
88                 [Browsable (false)]
89                 public object SyncRoot {
90                         get {
91                                 return this;
92                         }
93                 }
94
95
96                 #endregion
97
98                 #region Methods
99
100                 /// <summary>
101                 /// Copies all the elements in the current InternalDataCollectionBase to a one-
102                 /// dimensional Array, starting at the specified InternalDataCollectionBase index.
103                 /// </summary>
104                 public void CopyTo(Array ar, int index) 
105                 {
106                         list.CopyTo (ar, index);
107
108                 }
109
110                 /// <summary>
111                 /// Gets an IEnumerator for the collection.
112                 /// </summary>
113                 public IEnumerator GetEnumerator() 
114                 {
115                         return list.GetEnumerator ();
116                 }
117
118                 #endregion
119         }
120 }