Add license and copyright to all source files in System.Data
[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 //
20 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
21 //
22 // Permission is hereby granted, free of charge, to any person obtaining
23 // a copy of this software and associated documentation files (the
24 // "Software"), to deal in the Software without restriction, including
25 // without limitation the rights to use, copy, modify, merge, publish,
26 // distribute, sublicense, and/or sell copies of the Software, and to
27 // permit persons to whom the Software is furnished to do so, subject to
28 // the following conditions:
29 // 
30 // The above copyright notice and this permission notice shall be
31 // included in all copies or substantial portions of the Software.
32 // 
33 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
35 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
36 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
37 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
38 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
39 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 //
41
42 using System;
43 using System.Collections;
44 using System.ComponentModel;
45
46 namespace System.Data
47 {
48         /// <summary>
49         /// Base class for System.Data collection classes 
50         /// that are used within a DataTable object
51         /// to represent a collection of 
52         /// relations, tables, rows, columns, and constraints
53         /// </summary>
54
55         public class InternalDataCollectionBase : ICollection, IEnumerable 
56         {
57                 #region Fields
58
59                 private ArrayList list = null;
60                 private bool readOnly = false;
61                 private bool synchronized = false; 
62
63                 #endregion
64
65                 #region Constructors
66
67                 public InternalDataCollectionBase() 
68                 {
69                         list = new ArrayList();
70                 }
71
72                 #endregion
73
74                 #region Properties
75         
76                 /// <summary>
77                 /// Gets the total number of elements in a collection.
78                 /// </summary>
79                 [Browsable (false)]
80                 public virtual int Count {
81                         get { return list.Count; }
82                 }
83
84                 /// <summary>
85                 /// Gets a value indicating whether the InternalDataCollectionBase is read-only.
86                 /// </summary>
87                 [Browsable (false)]
88                 public bool IsReadOnly {
89                         get { return readOnly; }
90                 }
91
92                 /// <summary>
93                 /// Gets a value indicating whether the InternalDataCollectionBase is synchronized.
94                 /// </summary>
95                 [Browsable (false)]
96                 public bool IsSynchronized {
97                         get { return synchronized; }
98                 }
99
100                 /// <summary>
101                 /// Gets the items of the collection as a list.
102                 /// </summary>
103                 protected virtual ArrayList List {
104                         get { return list; }
105                 }
106
107                 /// <summary>
108                 /// Gets an object that can be used to synchronize the collection.
109                 /// </summary>
110                 [Browsable (false)]
111                 public object SyncRoot {
112                         get {
113                                 return this;
114                         }
115                 }
116
117
118                 #endregion
119
120                 #region Methods
121
122                 /// <summary>
123                 /// Copies all the elements in the current InternalDataCollectionBase to a one-
124                 /// dimensional Array, starting at the specified InternalDataCollectionBase index.
125                 /// </summary>
126                 public void CopyTo(Array ar, int index) 
127                 {
128                         list.CopyTo (ar, index);
129
130                 }
131
132                 /// <summary>
133                 /// Gets an IEnumerator for the collection.
134                 /// </summary>
135                 public IEnumerator GetEnumerator() 
136                 {
137                         return list.GetEnumerator ();
138                 }
139
140                 #endregion
141         }
142 }