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
59 private ArrayList list = null;
60 private bool readOnly = false;
61 private bool synchronized = false;
67 public InternalDataCollectionBase()
69 list = new ArrayList();
77 /// Gets the total number of elements in a collection.
80 public virtual int Count {
81 get { return list.Count; }
85 /// Gets a value indicating whether the InternalDataCollectionBase is read-only.
88 public bool IsReadOnly {
89 get { return readOnly; }
93 /// Gets a value indicating whether the InternalDataCollectionBase is synchronized.
96 public bool IsSynchronized {
97 get { return synchronized; }
101 /// Gets the items of the collection as a list.
103 protected virtual ArrayList List {
108 /// Gets an object that can be used to synchronize the collection.
111 public object SyncRoot {
123 /// Copies all the elements in the current InternalDataCollectionBase to a one-
124 /// dimensional Array, starting at the specified InternalDataCollectionBase index.
130 void CopyTo (Array ar, int index)
132 list.CopyTo (ar, index);
136 /// Gets an IEnumerator for the collection.
142 IEnumerator GetEnumerator ()
144 return list.GetEnumerator ();
147 internal Array ToArray (Type type)
149 return list.ToArray (type);