2 // System.Data.ObjectSpaces.ObjectList.cs
\r
5 // Mark Easton (mark.easton@blinksoftware.co.uk)
\r
6 // Tim Coleman (tim@timcoleman.com)
\r
8 // (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
\r
9 // Copyright (C) Tim Coleman, 2003-2004
\r
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System.Collections;
\r
36 using System.Reflection;
\r
38 namespace System.Data.ObjectSpaces
\r
41 public class ObjectList : ICollection, IEnumerable, IList
\r
47 #endregion // Fields
\r
49 #region Constructors
\r
51 public ObjectList ()
\r
52 : this (typeof (ArrayList), null)
\r
56 public ObjectList (Type type, object[] parameters)
\r
59 throw new ObjectException ();
\r
61 bool isIList = false;
\r
62 foreach (Type t in type.GetInterfaces ())
\r
63 if (t.Equals (typeof (IList))) {
\r
69 throw new ObjectException ();
\r
71 Type[] types = Type.EmptyTypes;
\r
72 if (parameters != null)
\r
73 types = Type.GetTypeArray (parameters);
\r
75 ConstructorInfo ci = type.GetConstructor (types);
\r
76 list = (IList) ci.Invoke (parameters);
\r
79 #endregion // Constructors
\r
84 get { return InnerList.Count; }
\r
87 bool ICollection.IsSynchronized {
\r
88 get { return InnerList.IsSynchronized; }
\r
91 object ICollection.SyncRoot {
\r
92 get { return InnerList.SyncRoot; }
\r
95 public IList InnerList {
\r
96 get { return list; }
\r
99 public bool IsFixedSize {
\r
100 get { return InnerList.IsFixedSize; }
\r
103 public bool IsReadOnly {
\r
104 get { return InnerList.IsReadOnly; }
\r
107 public object this [int index] {
\r
108 get { return InnerList [index]; }
\r
109 set { InnerList [index] = value; }
\r
112 #endregion // Properties
\r
116 public int Add (object value)
\r
118 return InnerList.Add (value);
\r
121 public void Clear ()
\r
123 InnerList.Clear ();
\r
126 public bool Contains (object value)
\r
128 return InnerList.Contains (value);
\r
131 public void CopyTo (Array array, int index)
\r
133 InnerList.CopyTo (array, index);
\r
136 public IEnumerator GetEnumerator ()
\r
138 return InnerList.GetEnumerator ();
\r
141 public int IndexOf (object value)
\r
143 return InnerList.IndexOf (value);
\r
146 public void Insert (int index, object value)
\r
148 InnerList.Insert (index, value);
\r
151 public void Remove (object value)
\r
153 InnerList.Remove (value);
\r
156 public void RemoveAt (int index)
\r
158 InnerList.RemoveAt (index);
\r
161 #endregion // Methods
\r