// (c) copyright 2002 Daniel Morgan
//
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System;
using System.Data.Common;
using System.ComponentModel;
namespace System.Data
{
- public class DataColumnPropertyDescriptor : PropertyDescriptor
+ internal class DataColumnPropertyDescriptor : PropertyDescriptor
{
private bool readOnly = true;
private Type componentType = null;
private Type propertyType = null;
- private PropertyInfo prop = null;
+ //private PropertyInfo prop = null;
private int columnIndex = 0;
public DataColumnPropertyDescriptor (string name, int columnIndex, Attribute [] attrs)
this.columnIndex = columnIndex;
}
+ public DataColumnPropertyDescriptor (DataColumn dc)
+ : base (dc.ColumnName, null)
+ {
+ this.columnIndex = dc.Ordinal;
+ this.componentType = typeof(DataRowView);
+ this.propertyType = dc.DataType;
+ this.readOnly = dc.ReadOnly;
+ }
+
public void SetReadOnly (bool value)
{
readOnly = value;
propertyType = type;
}
- private PropertyInfo GetPropertyInfo ()
- {
- string defaultMemberName = "";
- object[] attribs = componentType.GetCustomAttributes (true);\r
- \r
- for (int at = 0; at < attribs.Length; at++) {\r
- if (attribs[at] is DefaultMemberAttribute) {\r
- defaultMemberName = ((DefaultMemberAttribute) attribs[at]).MemberName;\r
- break;\r
- }\r
- }\r
-\r
- // FIXME: what do I do if a DefaultMemeberAttribute is not found?\r
- // should I try looking for DefaultPropertyAttribute?\r
- if (defaultMemberName.Equals(""))\r
- throw new Exception("Default property not found.");\r
-\r
- Type[] parmTypes = new Type[1];\r
- parmTypes[0] = propertyType;\r
- PropertyInfo propertyInfo = componentType.GetProperty (defaultMemberName, parmTypes);
- return propertyInfo;
- }
-
public override object GetValue (object component)
{
// FIXME: what is the correct way to Get a Value?
/*
if (prop == null)
prop = GetPropertyInfo ();
- \r
- // FIXME: should I allow multiple parameters? \r
- object[] parms = new object[1];\r
- parms[0] = base.Name;\r
+
+ // FIXME: should I allow multiple parameters?
+ object[] parms = new object[1];
+ parms[0] = base.Name;
return prop.GetValue (component, parms);
*/
}
// FIXME: what really happens if read only?
throw new Exception("Property is ReadOnly");
}
- \r
- // FIXME: should I allow multiple parameters?\r
- object[] parms = new Object[1];\r
- parms[0] = base.Name;\r
+
+ // FIXME: should I allow multiple parameters?
+ object[] parms = new Object[1];
+ parms[0] = base.Name;
prop.SetValue (component, value, parms);
*/
}
return propertyType;
}
}
- }\r
+ }
}