2003-02-18 Alan Tam <Tam@SiuLung.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                 private ArrayList list = null;
37                 private bool readOnly = false;
38                 private bool synchronized = false; 
39
40                 #endregion
41
42                 #region Constructors
43
44                 public InternalDataCollectionBase() 
45                 {
46                         list = new ArrayList();
47                 }
48
49                 #endregion
50
51                 #region Properties
52         
53                 /// <summary>
54                 /// Gets the total number of elements in a collection.
55                 /// </summary>
56                 [Browsable (false)]
57                 public virtual int Count {
58                         get { return list.Count; }
59                 }
60
61                 /// <summary>
62                 /// Gets a value indicating whether the InternalDataCollectionBase is read-only.
63                 /// </summary>
64                 [Browsable (false)]
65                 public bool IsReadOnly {
66                         get { return readOnly; }
67                 }
68
69                 /// <summary>
70                 /// Gets a value indicating whether the InternalDataCollectionBase is synchronized.
71                 /// </summary>
72                 [Browsable (false)]
73                 public bool IsSynchronized {
74                         get { return synchronized; }
75                 }
76
77                 /// <summary>
78                 /// Gets the items of the collection as a list.
79                 /// </summary>
80                 protected virtual ArrayList List {
81                         get { return list; }
82                 }
83
84                 /// <summary>
85                 /// Gets an object that can be used to synchronize the collection.
86                 /// </summary>
87                 [Browsable (false)]
88                 public object SyncRoot {
89                         get {
90                                 return this;
91                         }
92                 }
93
94
95                 #endregion
96
97                 #region Methods
98
99                 /// <summary>
100                 /// Copies all the elements in the current InternalDataCollectionBase to a one-
101                 /// dimensional Array, starting at the specified InternalDataCollectionBase index.
102                 /// </summary>
103                 public void CopyTo(Array ar, int index) 
104                 {
105                         list.CopyTo (ar, index);
106
107                 }
108
109                 /// <summary>
110                 /// Gets an IEnumerator for the collection.
111                 /// </summary>
112                 public IEnumerator GetEnumerator() 
113                 {
114                         return list.GetEnumerator ();
115                 }
116
117                 #endregion
118         }
119 }