2006-11-28 Nagappan A <anagappan@novell.com>
+ * XmlSchemaDataImporter.cs: Fixed 2.0 profile compilation
+ warnings. Using AttributeSchemaType instead of AttributeType and
+ ElementSchemaType instead of ElementType.
+
+ * TypedDataSetGenerator.cs: Modified the profile check from
+ !NET_1_1 to !NET_1_0, as this class is obsolete from 1.1 profile.
+
+ * DataRelationCollection.cs (Item): Modified the property Item as
+ abstract and implemented it in DataSetRelationCollection and
+ DataTableRelationCollection classes.
+
+ * DataRowView.cs: Remove bogus MonoTODOs.
+
+ * ForeignKeyConstraint.cs (ForeignKeyConstraint): Implemented
+ 2.0 profile's missing constructor.
+
+ * XmlDataLoader.cs (StringToObject): Modify XmlConvert.ToDateTime
+ to use XmlDateTimeSerializationMode, as the default ToDataTime
+ method id obsolete.
+
+ * XmlDataReader.cs (StringToObject): Modify XmlConvert.ToDateTime
+ to use XmlDateTimeSerializationMode, as the default ToDataTime
+ method id obsolete.
+
+ * DataView.cs (IsInitialized): Added browsable attribute.
+
+ * DataViewSettingCollection.cs (CopyTo): Implemented missing 2.0
+ API.
+
* DataRelation.cs (DataRelation): Added 2.0 profile constructor to
take parentTableNameSpace and childTableNameSpace as argument.
(FinishInit): Update parentTableNameSpace and childTableNameSpace,
(WriteXmlSchema): Throw InvalidOperationException, when table name
is empty. When DataSet Namespace is set, append that with '_x003A_'
and table name.
+ (IsInitialized): Added browsable attribute.
* DataSet.cs (Load): Throw ArgumentNullException, when reader
argument is null.
+ (IsInitialized): Added browsable attribute.
+ (WriteObjectXml): Modify XmlConvert.ToDateTime to use
+ XmlDateTimeSerializationMode, as the default ToDataTime method id
+ obsolete.
* XmlSchemaWriter.cs (WriteSchema): Modified UseCurrentCulture to
UseCurrentLocale.
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)
return base.List;
}
}
+
+ public override DataRelation this [string name] {
+ get {
+ int index = IndexOf (name, true);
+ return index < 0 ? null : (DataRelation) List[index];
+ }
+ }
+
+ /// <summary>
+ /// Gets the DataRelation object at the specified index.
+ /// </summary>
+ public override DataRelation this [int index] {
+ get {
+ if (index < 0 || index >= List.Count)
+ throw new IndexOutOfRangeException (String.Format ("Cannot find relation {0}.", index));
+
+ return (DataRelation)List [index];
+ }
+ }
}
/// <summary>
return dataTable.DataSet;
}
+ public override DataRelation this [string name] {
+ get {
+ int index = IndexOf (name, true);
+ return index < 0 ? null : (DataRelation) List[index];
+ }
+ }
+
+ /// <summary>
+ /// Gets the DataRelation object at the specified index.
+ /// </summary>
+ public override DataRelation this [int index] {
+ get {
+ if (index < 0 || index >= List.Count)
+ throw new IndexOutOfRangeException (String.Format ("Cannot find relation {0}.", index));
+
+ return (DataRelation)List [index];
+ }
+ }
+
/// <summary>
/// Performs verification on the table.
/// </summary>
/// <param name="relation">The relation to check.</param>
protected override void AddCore (DataRelation relation)
{
- if (dataTable.ParentRelations == this && relation.ChildTable != dataTable)
- throw new ArgumentException ("Cannot add a relation to this table's " +
- "ParentRelations where this table is not" +
- " the Child table.");
-
- if (dataTable.ChildRelations == this && relation.ParentTable != dataTable)
- throw new ArgumentException("Cannot add a relation to this table's " +
- "ChildRelations where this table is not" +
- " the Parent table.");
+ if (dataTable.ParentRelations == this && relation.ChildTable != dataTable)
+ throw new ArgumentException ("Cannot add a relation to this table's " +
+ "ParentRelations where this table is not" +
+ " the Child table.");
+
+ if (dataTable.ChildRelations == this && relation.ParentTable != dataTable)
+ throw new ArgumentException("Cannot add a relation to this table's " +
+ "ChildRelations where this table is not" +
+ " the Parent table.");
dataTable.DataSet.Relations.Add(relation);
- base.AddCore (relation);
-
+ base.AddCore (relation);
}
protected override void RemoveCore (DataRelation relation)
/// <summary>
/// Gets the DataRelation object specified by name.
/// </summary>
- public DataRelation this [string name] {
- get {
- int index = IndexOf (name, true);
- return index < 0 ? null : (DataRelation) List[index];
- }
+ public abstract DataRelation this [string name] {
+ get;
}
/// <summary>
/// Gets the DataRelation object at the specified index.
/// </summary>
- public DataRelation this [int index] {
- get {
- if (index < 0 || index >= List.Count)
- throw new IndexOutOfRangeException (String.Format ("Cannot find relation {0}.", index));
-
- return (DataRelation)List [index];
- }
+ public abstract DataRelation this [int index] {
+ get;
}
// "Detached", and when this.EndEdit() is invoked, the row\r
// will be added to the table.\r
public bool IsNew {\r
- [MonoTODO]\r
get {\r
return Row == DataView._lastAdded;\r
}\r
}\r
\r
public DataRow Row {\r
- [MonoTODO]\r
get {\r
return _dataRow;\r
}\r
}\r
\r
public DataRowVersion RowVersion {\r
- [MonoTODO]\r
get {\r
DataRowVersion version = DataView.GetRowVersion(_index);\r
if (version != DataRowVersion.Original)\r
}\r
}\r
\r
- [MonoTODO]\r
public override int GetHashCode() {\r
return _dataRow.GetHashCode();\r
} \r
\r
#region ICustomTypeDescriptor implementations\r
\r
- [MonoTODO]\r
AttributeCollection ICustomTypeDescriptor.GetAttributes ()\r
{\r
System.ComponentModel.AttributeCollection attributes;\r
[DataSysDescription ("Indicates that the DataSet has errors.")]\r
#endif\r
public bool HasErrors {\r
- [MonoTODO]\r
get {\r
for (int i = 0; i < Tables.Count; i++) {\r
if (Tables[i].HasErrors)\r
}\r
\r
#if NET_2_0\r
+ [Browsable (false)]\r
public bool IsInitialized {\r
get { return dataSetInitialized;}\r
}\r
}\r
}\r
\r
- public void Load (IDataReader reader, LoadOption loadOption, FillErrorEventHandler errorHandler, params DataTable[] tables)\r
+ public virtual void Load (IDataReader reader, LoadOption loadOption,\r
+ FillErrorEventHandler errorHandler, params DataTable[] tables)\r
{\r
if (reader == null) {\r
throw new ArgumentNullException ("Value cannot be null. Parameter name: reader");\r
case TypeCode.Char:\r
return XmlConvert.ToString ((Char) o);\r
case TypeCode.DateTime:\r
+#if NET_2_0\r
+ return XmlConvert.ToString ((DateTime) o, XmlDateTimeSerializationMode.Unspecified);\r
+#else\r
return XmlConvert.ToString ((DateTime) o);\r
+#endif\r
case TypeCode.Decimal:\r
return XmlConvert.ToString ((Decimal) o);\r
case TypeCode.Double:\r
}\r
\r
#if NET_2_0\r
+ [Browsable (false)]\r
public bool IsInitialized {\r
get { return tableInitialized;}\r
}\r
[DefaultProperty ("Table")]\r
[DesignerAttribute ("Microsoft.VSDesigner.Data.VS.DataViewDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]\r
#if NET_2_0\r
- public class DataView : MarshalByValueComponent, IBindingList, IList, ICollection, IEnumerable, ITypedList, ISupportInitialize, IBindingListView\r
+ public class DataView : MarshalByValueComponent, IBindingList, IList, ICollection, IEnumerable, ITypedList, ISupportInitialize, IBindingListView, ISupportInitializeNotification\r
#else\r
public class DataView : MarshalByValueComponent, IBindingList, IList, ICollection, IEnumerable, ITypedList, ISupportInitialize\r
#endif\r
bool allowEdit = true;\r
bool allowDelete = true;\r
bool applyDefaultSort = false;\r
- bool isSorted = false;\r
+ //bool isSorted = false;\r
\r
bool isOpen = false;\r
\r
}\r
\r
#if NET_2_0\r
+ [Browsable (false)]\r
public bool IsInitialized {\r
get { return dataViewInitialized;}\r
}\r
settingList.CopyTo (ar, index);
}
+#if NET_2_0
+ public void CopyTo (DataViewSetting [] ar, int index)
+ {
+ settingList.CopyTo (ar, index);
+ }
+#endif
+
public IEnumerator GetEnumerator ()
{
return settingList.GetEnumerator ();
private Rule _updateRule = Rule.Cascade;
private AcceptRejectRule _acceptRejectRule = AcceptRejectRule.None;
private string _parentTableName;
+#if NET_2_0
+ private string _parentTableNamespace;
+#endif
private string _childTableName;
//FIXME: remove those; and use only DataColumns[]
_validateColumns (parentColumns, childColumns);
_parentColumns = parentColumns;
_childColumns = childColumns;
+#if NET_2_0
+ parentTable.Namespace = _parentTableNamespace;
+#endif
InitInProgress = false;
}
#if NET_2_0
- [MonoTODO]
[Browsable (false)]
public ForeignKeyConstraint (string constraintName, string parentTableName, string parentTableNamespace, string[] parentColumnNames, string[] childColumnNames, AcceptRejectRule acceptRejectRule, Rule deleteRule, Rule updateRule)
{
- throw new NotImplementedException ();
+ InitInProgress = true;
+ base.ConstraintName = constraintName;
+
+ // "parentTableName" is searched in the "DataSet" to which the "DataTable"
+ // from which AddRange() is called
+ // childTable is the "DataTable" which calls AddRange()
+
+ // Keep reference to parentTableName to resolve later
+ _parentTableName = parentTableName;
+ _parentTableNamespace = parentTableNamespace;
+
+ // Keep reference to parentColumnNames to resolve later
+ _parentColumnNames = parentColumnNames;
+
+ // Keep reference to childColumnNames to resolve later
+ _childColumnNames = childColumnNames;
+
+ _acceptRejectRule = acceptRejectRule;
+ _deleteRule = deleteRule;
+ _updateRule = updateRule;
}
#endif
namespace System.Data
{
-#if !NET_1_1
+#if !NET_1_0
[Obsolete ("TypedDataSetGenerator class will be removed in a future release. Please use System.Data.Design.TypedDataSetGenerator in System.Design.dll.")]
#endif
public class TypedDataSetGenerator
{
}
- [MonoTODO ("See CustomDataclassGenerator.cs")]
public static void Generate (DataSet dataSet,
CodeNamespace codeNamespace,
ICodeGenerator codeGen)
{
+ // See CustomDataclassGenerator.cs
CustomDataClassGenerator.CreateDataSetClasses (
dataSet, codeNamespace, codeGen, null);
}
case TypeCode.Boolean: return XmlConvert.ToBoolean (value);
case TypeCode.Byte: return XmlConvert.ToByte (value);
case TypeCode.Char: return (char)XmlConvert.ToInt32 (value);
+#if NET_2_0
+ case TypeCode.DateTime: return XmlConvert.ToDateTime (value, XmlDateTimeSerializationMode.Unspecified);
+#else
case TypeCode.DateTime: return XmlConvert.ToDateTime (value);
+#endif
case TypeCode.Decimal: return XmlConvert.ToDecimal (value);
case TypeCode.Double: return XmlConvert.ToDouble (value);
case TypeCode.Int16: return XmlConvert.ToInt16 (value);
case TypeCode.Boolean: return XmlConvert.ToBoolean (value);\r
case TypeCode.Byte: return XmlConvert.ToByte (value);\r
case TypeCode.Char: return (char)XmlConvert.ToInt32 (value);\r
+#if NET_2_0\r
+ case TypeCode.DateTime: return XmlConvert.ToDateTime (value, XmlDateTimeSerializationMode.Unspecified);\r
+#else\r
case TypeCode.DateTime: return XmlConvert.ToDateTime (value);\r
+#endif\r
case TypeCode.Decimal: return XmlConvert.ToDecimal (value);\r
case TypeCode.Double: return XmlConvert.ToDouble (value);\r
case TypeCode.Int16: return XmlConvert.ToInt16 (value);\r
e.Name = "bar";
s.Items.Add (e);
s.Compile (null);
+#if NET_2_0
+ schemaIntegerType = ((XmlSchemaSimpleType) a.AttributeSchemaType).Datatype;
+ schemaDecimalType = ((XmlSchemaSimpleType) b.AttributeSchemaType).Datatype;
+ schemaAnyType = e.ElementSchemaType as XmlSchemaComplexType;
+#else
schemaIntegerType = a.AttributeType as XmlSchemaDatatype;
schemaDecimalType = b.AttributeType as XmlSchemaDatatype;
schemaAnyType = e.ElementType as XmlSchemaComplexType;
+#endif
}
#region Fields
if (datasetElement == null &&
IsDataSetElement (el))
datasetElement = el;
+#if NET_2_0
+ if (el.ElementSchemaType is XmlSchemaComplexType &&
+ el.ElementSchemaType != schemaAnyType)
+#else
if (el.ElementType is XmlSchemaComplexType &&
-el.ElementType != schemaAnyType)
+ el.ElementType != schemaAnyType)
+#endif
targetElements.Add (obj);
}
}
foreach (XmlSchemaObject obj in schema.Items) {
if (obj is XmlSchemaElement) {
XmlSchemaElement el = obj as XmlSchemaElement;
+#if NET_2_0
+ if (el.ElementSchemaType is XmlSchemaComplexType &&
+ el.ElementSchemaType != schemaAnyType)
+#else
if (el.ElementType is XmlSchemaComplexType &&
-el.ElementType != schemaAnyType)
+ el.ElementType != schemaAnyType)
+#endif
targetElements.Add (obj);
}
}
{
XmlSchemaElement el = p as XmlSchemaElement;
if (el != null) {
- XmlSchemaComplexType ct = el.ElementType as XmlSchemaComplexType;
+ XmlSchemaComplexType ct = null;
+#if NET_2_0
+ ct = el.ElementSchemaType as XmlSchemaComplexType;
+#else
+ ct = el.ElementType as XmlSchemaComplexType;
+#endif
if (ct == null || ct == schemaAnyType)
return true; // column element
if (ct.AttributeUses.Count > 0)
return;
// If type is not complex, just skip this element
+#if NET_2_0
+ if (! (el.ElementSchemaType is XmlSchemaComplexType && el.ElementSchemaType != schemaAnyType))
+#else
if (! (el.ElementType is XmlSchemaComplexType && el.ElementType != schemaAnyType))
+#endif
return;
if (IsDataSetElement (el)) {
}
// Process content type particle (and create DataTable)
- XmlSchemaComplexType ct = el.ElementType as XmlSchemaComplexType;
+ XmlSchemaComplexType ct = null;
+#if NET_2_0
+ ct = el.ElementSchemaType as XmlSchemaComplexType;
+#else
+ ct = el.ElementType as XmlSchemaComplexType;
+#endif
XmlSchemaParticle p = ct != null ? ct.ContentTypeParticle : null;
if (p != null)
HandleDataSetContentTypeParticle (p);
{
XmlSchemaElement el = p as XmlSchemaElement;
if (el != null) {
+#if NET_2_0
+ if (el.ElementSchemaType is XmlSchemaComplexType && el.RefName != el.QualifiedName)
+#else
if (el.ElementType is XmlSchemaComplexType && el.RefName != el.QualifiedName)
+#endif
ProcessDataTableElement (el);
}
else if (p is XmlSchemaGroupBase) {
// Handle complex type (NOTE: It is (or should be)
// impossible the type is other than complex type).
- XmlSchemaComplexType ct = (XmlSchemaComplexType) el.ElementType;
+ XmlSchemaComplexType ct = null;
+#if NET_2_0
+ ct = (XmlSchemaComplexType) el.ElementSchemaType;
+#else
+ ct = (XmlSchemaComplexType) el.ElementType;
+#endif
// Handle attributes
foreach (DictionaryEntry de in ct.AttributeUses)
DataColumn col = new DataColumn ();
col.ColumnName = attr.QualifiedName.Name;
col.Namespace = attr.QualifiedName.Namespace;
- XmlSchemaDatatype dt = GetSchemaPrimitiveType (attr.AttributeType);
+ XmlSchemaDatatype dt = null;
+#if NET_2_0
+ dt = GetSchemaPrimitiveType (((XmlSchemaSimpleType) attr.AttributeSchemaType).Datatype);
+#else
+ dt = GetSchemaPrimitiveType (attr.AttributeType);
+#endif
// This complicated check comes from the fact that
// MS.NET fails to map System.Object to anyType (that
// will cause ReadTypedObject() fail on XmlValidatingReader).
if (attr.Use == XmlSchemaUse.Required)
col.AllowDBNull = false;
+#if NET_2_0
+ FillFacet (col, attr.AttributeSchemaType as XmlSchemaSimpleType);
+#else
FillFacet (col, attr.AttributeType as XmlSchemaSimpleType);
+#endif
// Call this method after filling the name
ImportColumnMetaInfo (attr, attr.QualifiedName, col);
col.DefaultValue = GetElementDefaultValue (el);
col.AllowDBNull = (el.MinOccurs == 0);
+#if NET_2_0
+ if (el.ElementSchemaType is XmlSchemaComplexType && el.ElementSchemaType != schemaAnyType)
+#else
if (el.ElementType is XmlSchemaComplexType && el.ElementType != schemaAnyType)
+#endif
FillDataColumnComplexElement (parent, el, col);
else if (el.MaxOccurs != 1)
FillDataColumnRepeatedSimpleElement (parent, el, col);
cc2.Namespace = el.QualifiedName.Namespace;
cc2.ColumnMapping = MappingType.SimpleContent;
cc2.AllowDBNull = false;
+#if NET_2_0
+ cc2.DataType = ConvertDatatype (GetSchemaPrimitiveType (el.ElementSchemaType));
+#else
cc2.DataType = ConvertDatatype (GetSchemaPrimitiveType (el.ElementType));
+#endif
dt.Columns.Add (cc2);
dt.Columns.Add (cc);
col.ColumnName = XmlHelper.Decode (el.QualifiedName.Name);
col.Namespace = el.QualifiedName.Namespace;
col.ColumnMapping = MappingType.Element;
+#if NET_2_0
+ col.DataType = ConvertDatatype (GetSchemaPrimitiveType (el.ElementSchemaType));
+ FillFacet (col, el.ElementSchemaType as XmlSchemaSimpleType);
+#else
col.DataType = ConvertDatatype (GetSchemaPrimitiveType (el.ElementType));
FillFacet (col, el.ElementType as XmlSchemaSimpleType);
+#endif
ImportColumnMetaInfo (el, el.QualifiedName, col);