2 // System.Data.InternalDataCollectionBase.cs
6 // DataColumnCollection
8 // DataRelationCollection
9 // DataConstraintCollection
12 // Daniel Morgan <danmorg@sc.rr.com>
13 // Tim Coleman <tim@timcoleman.com>
15 // (C) Copyright 2002 Daniel Morgan
16 // (C) Copyright 2002 Tim Coleman
20 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
30 // The above copyright notice and this permission notice shall be
31 // included in all copies or substantial portions of the Software.
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.
43 using System.Collections;
44 using System.ComponentModel;
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
55 public class InternalDataCollectionBase : ICollection, IEnumerable {
58 private ArrayList list = null;
59 private bool readOnly = false;
60 private bool synchronized = false;
66 public InternalDataCollectionBase ()
68 list = new ArrayList();
76 /// Gets the total number of elements in a collection.
79 public virtual int Count {
80 get { return list.Count; }
84 /// Gets a value indicating whether the InternalDataCollectionBase is read-only.
87 public bool IsReadOnly {
88 get { return readOnly; }
92 /// Gets a value indicating whether the InternalDataCollectionBase is synchronized.
95 public bool IsSynchronized {
96 get { return synchronized; }
100 /// Gets the items of the collection as a list.
102 protected virtual ArrayList List {
107 /// Gets an object that can be used to synchronize the collection.
110 public object SyncRoot {
120 /// Copies all the elements in the current InternalDataCollectionBase to a one-
121 /// dimensional Array, starting at the specified InternalDataCollectionBase index.
127 void CopyTo (Array ar, int index)
129 list.CopyTo (ar, index);
133 /// Gets an IEnumerator for the collection.
139 IEnumerator GetEnumerator ()
141 return list.GetEnumerator ();
144 internal Array ToArray (Type type)
146 return list.ToArray (type);