**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Data / System.Data / DataRowView.cs
blobe471e5da6dcd8ae44e5a0a4b005bf85ee004ddd9
1 //
2 // System.Data.DataRowView.cs
3 //
4 // Author:
5 // Rodrigo Moya <rodrigo@ximian.com>
6 // Miguel de Icaza <miguel@ximian.com>
7 // Daniel Morgan <danmorg@sc.rr.com>
8 //
9 // (C) Ximian, Inc 2002
10 // (C) Daniel Morgan 2002
14 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
23 //
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
26 //
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System;
37 using System.Collections;
38 using System.ComponentModel;
39 using System.Reflection;
41 namespace System.Data
43 /// <summary>
44 /// Represents a customized view of a DataRow exposed as a fully featured Windows Forms control.
45 /// </summary>
46 public class DataRowView : ICustomTypeDescriptor, IEditableObject, IDataErrorInfo
48 #region Fields
50 DataView dataView;
51 DataRow dataRow;
52 DataRowVersion rowVersion = DataRowVersion.Default;
54 // FIXME: what are the defaults?
55 bool isEdit = false;
56 bool isNew = false;
58 #endregion // Fields
60 #region Constructors
62 internal DataRowView (DataView dataView, DataRow row) : this(dataView, row, false){
65 internal DataRowView (DataView dataView, DataRow row, bool isNew) {
66 this.dataView = dataView;
67 this.dataRow = row;
68 this.isNew = isNew;
71 #endregion // Constructors
73 #region Methods
75 public override bool Equals(object other)
77 return (other != null &&
78 other is DataRowView &&
79 ((DataRowView)other).dataRow != null &&
80 ((DataRowView)other).dataRow.Equals(this.dataRow));
83 [MonoTODO]
84 public void BeginEdit ()
86 // FIXME:
87 dataRow.BeginEdit();
88 isEdit = true;
91 [MonoTODO]
92 public void CancelEdit ()
94 // FIXME:
95 dataRow.CancelEdit();
96 isEdit = false;
99 [MonoTODO]
100 public DataView CreateChildView (DataRelation relation)
102 throw new NotImplementedException ();
105 [MonoTODO]
106 public DataView CreateChildView (string name)
108 throw new NotImplementedException ();
111 [MonoTODO]
112 public void Delete ()
114 throw new NotImplementedException ();
117 [MonoTODO]
118 public void EndEdit ()
120 // FIXME:
121 dataRow.EndEdit();
122 isEdit = false;
125 #endregion // Methods
127 #region Properties
129 public DataView DataView
131 [MonoTODO]
132 get {
133 return dataView;
137 public bool IsEdit {
138 [MonoTODO]
139 get {
140 return isEdit;
144 public bool IsNew {
145 [MonoTODO]
146 get {
147 return isNew;
151 [System.Runtime.CompilerServices.IndexerName("Item")]
152 public object this[string column] {
153 [MonoTODO]
154 get {
155 DataColumn dc = dataView.Table.Columns[column];
156 return dataRow[dc];
158 [MonoTODO]
159 set {
160 DataColumn dc = dataView.Table.Columns[column];
161 dataRow[dc] = value;
162 dataView.ChangedList(ListChangedType.ItemChanged,dc.Ordinal,-1);
166 // the compiler creates a DefaultMemeberAttribute from
167 // this IndexerNameAttribute
168 public object this[int column] {
169 [MonoTODO]
170 get {
171 DataColumn dc = dataView.Table.Columns[column];
172 return dataRow[dc];
174 [MonoTODO]
175 set {
176 DataColumn dc = dataView.Table.Columns[column];
177 dataRow[dc] = value;
182 public DataRow Row {
183 [MonoTODO]
184 get {
185 return dataRow;
189 public DataRowVersion RowVersion {
190 [MonoTODO]
191 get {
192 return rowVersion;
196 [MonoTODO]
197 public override int GetHashCode() {
198 throw new NotImplementedException ();
201 #endregion // Properties
203 #region ICustomTypeDescriptor implementations
205 [MonoTODO]
206 AttributeCollection ICustomTypeDescriptor.GetAttributes ()
208 System.ComponentModel.AttributeCollection attributes;
209 attributes = AttributeCollection.Empty;
210 return attributes;
213 [MonoTODO]
214 string ICustomTypeDescriptor.GetClassName ()
216 return "";
219 [MonoTODO]
220 string ICustomTypeDescriptor.GetComponentName ()
222 return null;
225 [MonoTODO]
226 TypeConverter ICustomTypeDescriptor.GetConverter ()
228 return null;
231 [MonoTODO]
232 EventDescriptor ICustomTypeDescriptor.GetDefaultEvent ()
234 return null;
237 [MonoTODO]
238 PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty ()
240 return null;
243 [MonoTODO]
244 object ICustomTypeDescriptor.GetEditor (Type editorBaseType)
246 return null;
249 [MonoTODO]
250 EventDescriptorCollection ICustomTypeDescriptor.GetEvents ()
252 return new EventDescriptorCollection(null);
255 [MonoTODO]
256 EventDescriptorCollection ICustomTypeDescriptor.GetEvents (Attribute [] attributes)
258 return new EventDescriptorCollection(null);
261 [MonoTODO]
262 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties ()
264 ITypedList typedList = (ITypedList) dataView;
265 return typedList.GetItemProperties(new PropertyDescriptor[0]);
268 [MonoTODO]
269 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties (Attribute [] attributes)
271 PropertyDescriptorCollection descriptors;
272 descriptors = ((ICustomTypeDescriptor) this).GetProperties ();
273 // TODO: filter out descriptors which do not contain
274 // any of those attributes
275 // except, those descriptors
276 // that contain DefaultMemeberAttribute
277 return descriptors;
280 [MonoTODO]
281 object ICustomTypeDescriptor.GetPropertyOwner (PropertyDescriptor pd)
283 return this;
286 #endregion // ICustomTypeDescriptor implementations
288 #region IDataErrorInfo implementation
290 string IDataErrorInfo.Error {
291 [MonoTODO]
292 get {
293 return ""; // FIXME
297 string IDataErrorInfo.this[string columnName] {
298 [MonoTODO]
299 get {
300 return ""; // FIXME
304 #endregion // IDataErrorInfo implementation