2002-10-07 Gonzalo Paniagua Javier <gonzalo@ximian.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                 protected ArrayList list = null;
37                 protected bool readOnly = false;
38                 protected bool synchronized = false; 
39
40                 #endregion
41
42                 #region Constructors
43
44                 [MonoTODO]
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                 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                 public bool IsReadOnly {
65                         get { return readOnly; }
66                 }
67
68                 /// <summary>
69                 /// Gets a value indicating whether the InternalDataCollectionBase is synchronized.
70                 /// </summary>
71                 public bool IsSynchronized {
72                         get { return synchronized; }
73                 }
74
75                 /// <summary>
76                 /// Gets the items of the collection as a list.
77                 /// </summary>
78                 protected internal virtual ArrayList List {
79                         get { return list; }
80                 }
81
82                 /// <summary>
83                 /// Gets an object that can be used to synchronize the collection.
84                 /// </summary>
85                 public object SyncRoot {
86                         [MonoTODO]
87                         get {
88                                 // FIXME: how do we sync?       
89                                 throw new NotImplementedException ();
90                         }
91                 }
92
93
94                 #endregion
95
96                 #region Methods
97
98                 /// <summary>
99                 /// Copies all the elements in the current InternalDataCollectionBase to a one-
100                 /// dimensional Array, starting at the specified InternalDataCollectionBase index.
101                 /// </summary>
102                 public void CopyTo(Array ar, int index) 
103                 {
104                         list.CopyTo (ar, index);
105
106                 }
107
108                 /// <summary>
109                 /// Gets an IEnumerator for the collection.
110                 /// </summary>
111                 public IEnumerator GetEnumerator() 
112                 {
113                         return list.GetEnumerator ();
114                 }
115
116                 #endregion
117         }
118 }