2 // System.Data.ObjectSpaces.ObjectSet.cs
\r
5 // Tim Coleman (tim@timcoleman.com)
\r
7 // Copyright (C) Tim Coleman, 2003-2004
\r
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Collections;
\r
34 using System.ComponentModel;
\r
35 using System.Data.ObjectSpaces.Schema;
\r
37 using System.Xml.Schema;
\r
38 using System.Xml.Serialization;
\r
40 namespace System.Data.ObjectSpaces
\r
42 public class ObjectSet : CollectionBase, IListSource, IXmlSerializable
\r
47 ObjectContext context;
\r
50 #endregion // Fields
\r
52 #region Constructors
\r
54 public ObjectSet (Type t, ObjectSchema oschema)
\r
56 da = DynamicAssembly.GetDynamicAssembly (t);
\r
58 context = new CommonObjectContext (oschema);
\r
62 : this (typeof (object), new ObjectSchema ())
\r
66 #endregion // Constructors
\r
71 public object this [int i] {
\r
72 get { return InnerList [i]; }
\r
73 set { InnerList [i] = value; }
\r
77 bool IListSource.ContainsListCollection {
\r
78 get { throw new NotImplementedException(); }
\r
81 internal ObjectContext ObjectContext {
\r
82 get { return context; }
\r
85 #endregion // Properties
\r
89 public void Add (object o)
\r
91 Type t = o.GetType ();
\r
92 if (t != da.UnderlyingType)
\r
93 throw new ObjectException (String.Format (Locale.GetText ("Wrong Object type '{0}' added to ObjectSet. ObjectSet type is '{1}'"), t.FullName, da.UnderlyingType.FullName));
\r
94 context.Add (o, ObjectState.Inserted);
\r
98 public void Add (ICollection c)
\r
100 foreach (object o in c)
\r
104 public void Add (object o, ObjectState state)
\r
106 Type t = o.GetType ();
\r
107 if (t != da.UnderlyingType)
\r
108 throw new ObjectException (String.Format (Locale.GetText ("Wrong Object type '{0}' added to ObjectSet. ObjectSet type is '{1}'"), t.FullName, da.UnderlyingType.FullName));
\r
109 context.Add (o, state);
\r
114 public void GetRemotingDiffGram (XmlWriter writer)
\r
116 throw new NotImplementedException ();
\r
119 IList IListSource.GetList ()
\r
125 XmlSchema IXmlSerializable.GetSchema()
\r
127 throw new NotImplementedException ();
\r
131 void IXmlSerializable.ReadXml (XmlReader reader)
\r
133 throw new NotImplementedException();
\r
137 void IXmlSerializable.WriteXml (XmlWriter writer)
\r
139 throw new NotImplementedException();
\r
143 protected override void OnInsertComplete (int index, object value)
\r
145 throw new NotImplementedException();
\r
149 protected override void OnRemoveComplete (int index, object value)
\r
151 throw new NotImplementedException();
\r
155 protected override void OnSetComplete (int index, object oldValue, object newValue)
\r
157 throw new NotImplementedException();
\r
161 public void StartTracking (Object o, InitialState state)
\r
163 throw new NotImplementedException();
\r
166 #endregion // Methods
\r