Author: anagappan
Date: 2006-11-28 01:32:38 -0500 (Tue, 28 Nov 2006)
New Revision: 68563
Modified:
trunk/mcs/class/System.Data/System.Data/ChangeLog
trunk/mcs/class/System.Data/System.Data/DataColumn.cs
trunk/mcs/class/System.Data/System.Data/DataRelation.cs
trunk/mcs/class/System.Data/System.Data/DataRelationCollection.cs
trunk/mcs/class/System.Data/System.Data/DataRowCollection.cs
trunk/mcs/class/System.Data/System.Data/DataSet.cs
trunk/mcs/class/System.Data/System.Data/DataTable.cs
trunk/mcs/class/System.Data/System.Data/XmlSchemaWriter.cs
Log:
2006-11-28 Nagappan A <[EMAIL PROTECTED]>
* DataRelation.cs (DataRelation): Added 2.0 profile constructor to
take parentTableNameSpace and childTableNameSpace as argument.
(FinishInit): Update parentTableNameSpace and childTableNameSpace,
when the string is not empty in 2.0 profile.
* DataRowCollection.cs: Implemented Count public property.
Added !NET_2_0 for List protected property, as it has been removed
in 2.0 prifle.
(IndexOf): Implemented new public method.
(CopyTo): Implemented new public override method.
(GetEnumerator): Implemented new public override method.
* DataTable.cs (Load): Throw ArgumentNullException, when reader
argument is null.
(WriteXmlSchema): Throw InvalidOperationException, when table name
is empty. When DataSet Namespace is set, append that with '_x003A_'
and table name.
* DataSet.cs (Load): Throw ArgumentNullException, when reader
argument is null.
* XmlSchemaWriter.cs (WriteSchema): Modified UseCurrentCulture to
UseCurrentLocale.
(WriteDataSetElement): Added minOccurs attribute.
(WriteConstraints): Check for tables length, if > 1 then add the
relations to XmlSchema.
Modified: trunk/mcs/class/System.Data/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data/ChangeLog 2006-11-28 05:37:13 UTC
(rev 68562)
+++ trunk/mcs/class/System.Data/System.Data/ChangeLog 2006-11-28 06:32:38 UTC
(rev 68563)
@@ -1,3 +1,32 @@
+2006-11-28 Nagappan A <[EMAIL PROTECTED]>
+
+ * DataRelation.cs (DataRelation): Added 2.0 profile constructor to
+ take parentTableNameSpace and childTableNameSpace as argument.
+ (FinishInit): Update parentTableNameSpace and childTableNameSpace,
+ when the string is not empty in 2.0 profile.
+
+ * DataRowCollection.cs: Implemented Count public property.
+ Added !NET_2_0 for List protected property, as it has been removed
+ in 2.0 prifle.
+ (IndexOf): Implemented new public method.
+ (CopyTo): Implemented new public override method.
+ (GetEnumerator): Implemented new public override method.
+
+ * DataTable.cs (Load): Throw ArgumentNullException, when reader
+ argument is null.
+ (WriteXmlSchema): Throw InvalidOperationException, when table name
+ is empty. When DataSet Namespace is set, append that with '_x003A_'
+ and table name.
+
+ * DataSet.cs (Load): Throw ArgumentNullException, when reader
+ argument is null.
+
+ * XmlSchemaWriter.cs (WriteSchema): Modified UseCurrentCulture to
+ UseCurrentLocale.
+ (WriteDataSetElement): Added minOccurs attribute.
+ (WriteConstraints): Check for tables length, if > 1 then add the
+ relations to XmlSchema.
+
2006-11-21 Nagappan A <[EMAIL PROTECTED]>
* DataView.cs: Added public event Initialized.
Modified: trunk/mcs/class/System.Data/System.Data/DataColumn.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataColumn.cs 2006-11-28
05:37:13 UTC (rev 68562)
+++ trunk/mcs/class/System.Data/System.Data/DataColumn.cs 2006-11-28
06:32:38 UTC (rev 68563)
@@ -786,16 +786,7 @@
#region Methods
-/* ??
[MonoTODO]
- protected internal void CheckNotAllowNull() {
- }
-
- [MonoTODO]
- protected void CheckUnique() {
- }
-*/
- [MonoTODO]
internal DataColumn Clone() {
DataColumn copy = new DataColumn ();
Modified: trunk/mcs/class/System.Data/System.Data/DataRelation.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataRelation.cs 2006-11-28
05:37:13 UTC (rev 68562)
+++ trunk/mcs/class/System.Data/System.Data/DataRelation.cs 2006-11-28
06:32:38 UTC (rev 68563)
@@ -71,6 +71,10 @@
string[] _childColumnNames;
bool _nested;
bool initInProgress = false;
+#if NET_2_0
+ string _parentTableNameSpace = String.Empty;
+ string _childTableNameSpace = String.Empty;
+#endif
#region Constructors
@@ -118,7 +122,6 @@
"matching column
types");
}
- [MonoTODO]
[Browsable (false)]
public DataRelation (string relationName, string
parentTableName, string childTableName, string[] parentColumnNames, string[]
childColumnNames, bool nested)
{
@@ -130,6 +133,25 @@
_nested = nested;
InitInProgress = true;
}
+
+#if NET_2_0
+ [Browsable (false)]
+ public DataRelation (string relationName, string
parentTableName,
+ string parentTableNameSpace, string
childTableName,
+ string childTableNameSpace, string[]
parentColumnNames,
+ string[] childColumnNames, bool nested)
+ {
+ _relationName = relationName;
+ _parentTableName = parentTableName;
+ _parentTableNameSpace = parentTableNameSpace;
+ _childTableName = childTableName;
+ _childTableNameSpace = childTableNameSpace;
+ _parentColumnNames = parentColumnNames;
+ _childColumnNames = childColumnNames;
+ _nested = nested;
+ InitInProgress = true;
+ }
+#endif
internal bool InitInProgress {
get { return initInProgress; }
@@ -165,14 +187,15 @@
this.createConstraints = false;
this.extendedProperties = new PropertyCollection ();
InitInProgress = false;
- }
#if NET_2_0
- [MonoTODO]
- public DataRelation (string relationName, string
parentTableName, string parentTableNamespace, string childTableName, string
childTableNamespace, string[] parentColumnNames, string[] childColumnNames,
bool nested)
- {
- throw new NotImplementedException ();
+ if (_parentTableNameSpace != String.Empty) {
+ parent.Namespace = _parentTableNameSpace;
+ }
+ if (_childTableNameSpace != String.Empty) {
+ child.Namespace = _childTableNameSpace;
+ }
+#endif
}
-#endif
#endregion // Constructors
Modified: trunk/mcs/class/System.Data/System.Data/DataRelationCollection.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataRelationCollection.cs
2006-11-28 05:37:13 UTC (rev 68562)
+++ trunk/mcs/class/System.Data/System.Data/DataRelationCollection.cs
2006-11-28 06:32:38 UTC (rev 68563)
@@ -246,7 +246,6 @@
/// Adds a DataRelation to the DataRelationCollection.
/// </summary>
/// <param name="relation">The DataRelation to add to the
collection.</param>
- [MonoTODO]
public void Add(DataRelation relation)
{
// To prevent endless recursion
@@ -259,6 +258,9 @@
try
{
+ CollectionChangeEventArgs e = new
CollectionChangeEventArgs (CollectionChangeAction.Add, this);
+ OnCollectionChanging (e);
+
this.AddCore (relation);
if(relation.RelationName == string.Empty)
relation.RelationName =
GenerateRelationName();
@@ -266,8 +268,8 @@
relation.ParentTable.ResetPropertyDescriptorsCache();
relation.ChildTable.ResetPropertyDescriptorsCache();
- CollectionChangeEventArgs e = new
CollectionChangeEventArgs(CollectionChangeAction.Add, this);
- OnCollectionChanged(e);
+ e = new CollectionChangeEventArgs
(CollectionChangeAction.Add, this);
+ OnCollectionChanged (e);
}
finally
{
@@ -397,7 +399,6 @@
/// Adds to the list
/// </summary>
/// <param name="relation">The relation to check.</param>
- [MonoTODO]
protected virtual void AddCore(DataRelation relation)
{
if (relation == null) {
@@ -570,9 +571,9 @@
}
[MonoTODO]
- protected internal virtual void OnCollectionChanging
(CollectionChangeEventArgs ccevent)
+ protected virtual void OnCollectionChanging
(CollectionChangeEventArgs ccevent)
{
- throw new NotImplementedException ();
+ //throw new NotImplementedException ();
}
public void Remove (DataRelation relation)
@@ -594,6 +595,8 @@
if (!(List.Contains(relation)))
throw new ArgumentException("Relation
doesnot belong to this Collection.");
+ OnCollectionChanging
(CreateCollectionChangeEvent (CollectionChangeAction.Remove));
+
RemoveCore (relation);
string name = "Relation" + index;
if (relation.RelationName == name)
@@ -623,7 +626,6 @@
Remove(relation);
}
- [MonoTODO]
protected virtual void RemoveCore(DataRelation relation)
{
// Remove from collection
Modified: trunk/mcs/class/System.Data/System.Data/DataRowCollection.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataRowCollection.cs
2006-11-28 05:37:13 UTC (rev 68562)
+++ trunk/mcs/class/System.Data/System.Data/DataRowCollection.cs
2006-11-28 06:32:38 UTC (rev 68563)
@@ -78,13 +78,22 @@
}
}
+ public override int Count
+ {
+ get {
+ return List.Count;
+ }
+ }
+
+#if !NET_2_0
/// <summary>
/// This member overrides InternalDataCollectionBase.List
/// </summary>
protected override ArrayList List
{
get { return base.List; }
- }
+ }
+#endif
/// <summary>
/// Adds the specified DataRow to the DataRowCollection object.
@@ -109,6 +118,23 @@
AddInternal(row);
}
+#if NET_2_0
+ public int IndexOf (DataRow row)
+ {
+ if (row == null)
+ return -1;
+
+ int i = 0;
+ foreach (DataRow dr in this) {
+ if (dr == row) {
+ return i;
+ }
+ i++;
+ }
+
+ return -1;
+ }
+#endif
internal void AddInternal (DataRow row) {
AddInternal (row, DataRowAction.Add);
}
@@ -199,11 +225,23 @@
return Find (keys) != null;
}
+#if NET_2_0
public void CopyTo (DataRow [] array, int index)
{
CopyTo ((Array) array, index);
}
+ public override void CopyTo (Array array, int index)
+ {
+ base.CopyTo (array, index);
+ }
+
+ public override IEnumerator GetEnumerator ()
+ {
+ return base.GetEnumerator ();
+ }
+#endif
+
/// <summary>
/// Gets the row specified by the primary key value.
/// </summary>
Modified: trunk/mcs/class/System.Data/System.Data/DataSet.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataSet.cs 2006-11-28 05:37:13 UTC
(rev 68562)
+++ trunk/mcs/class/System.Data/System.Data/DataSet.cs 2006-11-28 06:32:38 UTC
(rev 68563)
@@ -721,8 +721,9 @@
#if NET_2_0
public void Load (IDataReader reader, LoadOption loadOption,
params DataTable[] tables)
{
- if (reader == null)
- return;
+ if (reader == null) {
+ throw new ArgumentNullException ("Value cannot
be null. Parameter name: reader");
+ }
foreach (DataTable dt in tables) {
if (dt.DataSet == null || dt.DataSet != this) {
throw new ArgumentException ("Table " +
dt.TableName + " does not belong to this DataSet.");
@@ -734,8 +735,9 @@
public void Load (IDataReader reader, LoadOption loadOption,
params string[] tables)
{
- if (reader == null)
- return;
+ if (reader == null) {
+ throw new ArgumentNullException ("Value cannot
be null. Parameter name: reader");
+ }
foreach (string tableName in tables) {
DataTable dt = Tables [tableName];
@@ -750,8 +752,9 @@
public void Load (IDataReader reader, LoadOption loadOption,
FillErrorEventHandler errorHandler, params DataTable[] tables)
{
- if (reader == null)
- return;
+ if (reader == null) {
+ throw new ArgumentNullException ("Value cannot
be null. Parameter name: reader");
+ }
foreach (DataTable dt in tables) {
if (dt.DataSet == null || dt.DataSet != this) {
throw new ArgumentException ("Table " +
dt.TableName + " does not belong to this DataSet.");
Modified: trunk/mcs/class/System.Data/System.Data/DataTable.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataTable.cs 2006-11-28
05:37:13 UTC (rev 68562)
+++ trunk/mcs/class/System.Data/System.Data/DataTable.cs 2006-11-28
06:32:38 UTC (rev 68563)
@@ -1692,8 +1692,9 @@
/// </summary>
public void Load (IDataReader reader)
{
- if (reader == null)
- return;
+ if (reader == null) {
+ throw new ArgumentNullException ("Value cannot
be null. Parameter name: reader");
+ }
Load (reader, LoadOption.PreserveChanges);
}
@@ -1704,8 +1705,9 @@
/// </summary>
public void Load (IDataReader reader, LoadOption loadOption)
{
- if (reader == null)
- return;
+ if (reader == null) {
+ throw new ArgumentNullException ("Value cannot
be null. Parameter name: reader");
+ }
bool prevEnforceConstr = this.EnforceConstraints;
try {
this.EnforceConstraints = false;
@@ -1726,8 +1728,9 @@
public virtual void Load (IDataReader reader, LoadOption
loadOption, FillErrorEventHandler errorHandler)
{
- if (reader == null)
- return;
+ if (reader == null) {
+ throw new ArgumentNullException ("Value cannot
be null. Parameter name: reader");
+ }
bool prevEnforceConstr = this.EnforceConstraints;
try {
this.EnforceConstraints = false;
@@ -2490,6 +2493,9 @@
public void WriteXmlSchema (Stream stream)
{
+ if (TableName == "") {
+ throw new InvalidOperationException ("Cannot
serialize the DataTable. DataTable name is not set.");
+ }
XmlWriterSettings s = GetWriterSettings ();
s.OmitXmlDeclaration = false;
WriteXmlSchema (XmlWriter.Create (stream, s));
@@ -2497,6 +2503,9 @@
public void WriteXmlSchema (TextWriter writer)
{
+ if (TableName == "") {
+ throw new InvalidOperationException ("Cannot
serialize the DataTable. DataTable name is not set.");
+ }
XmlWriterSettings s = GetWriterSettings ();
s.OmitXmlDeclaration = false;
WriteXmlSchema (XmlWriter.Create (writer, s));
@@ -2504,6 +2513,9 @@
public void WriteXmlSchema (XmlWriter writer)
{
+ if (TableName == "") {
+ throw new InvalidOperationException ("Cannot
serialize the DataTable. DataTable name is not set.");
+ }
DataSet ds = DataSet;
DataSet tmp = null;
try {
@@ -2516,7 +2528,12 @@
col.Add (this);
DataTable [] tables = new DataTable [col.Count];
for (int i = 0; i < col.Count; i++) tables[i] =
col[i];
- XmlSchemaWriter.WriteXmlSchema (writer, tables,
null, TableName, ds.DataSetName);
+ string tableName;
+ if (ds.Namespace == "")
+ tableName = TableName;
+ else
+ tableName = ds.Namespace + "_x003A_" +
TableName;
+ XmlSchemaWriter.WriteXmlSchema (writer, tables,
null, tableName, ds.DataSetName);
} finally {
if (tmp != null)
ds.Tables.Remove (this);
@@ -2525,6 +2542,12 @@
public void WriteXmlSchema (string fileName)
{
+ if (fileName == "") {
+ throw new ArgumentException ("Empty path name
is not legal.");
+ }
+ if (TableName == "") {
+ throw new InvalidOperationException ("Cannot
serialize the DataTable. DataTable name is not set.");
+ }
XmlWriter xw = null;
try {
XmlWriterSettings s = GetWriterSettings ();
@@ -2532,13 +2555,17 @@
xw = XmlWriter.Create (fileName, s);
WriteXmlSchema (xw);
} finally {
- if (xw != null)
+ if (xw != null) {
xw.Close ();
+ }
}
}
public void WriteXmlSchema (Stream stream, bool writeHierarchy)
{
+ if (TableName == "") {
+ throw new InvalidOperationException ("Cannot
serialize the DataTable. DataTable name is not set.");
+ }
XmlWriterSettings s = GetWriterSettings ();
s.OmitXmlDeclaration = false;
WriteXmlSchema (XmlWriter.Create (stream, s),
writeHierarchy);
@@ -2546,6 +2573,9 @@
public void WriteXmlSchema (TextWriter writer, bool
writeHierarchy)
{
+ if (TableName == "") {
+ throw new InvalidOperationException ("Cannot
serialize the DataTable. DataTable name is not set.");
+ }
XmlWriterSettings s = GetWriterSettings ();
s.OmitXmlDeclaration = false;
WriteXmlSchema (XmlWriter.Create (writer, s),
writeHierarchy);
@@ -2553,6 +2583,9 @@
public void WriteXmlSchema (XmlWriter writer, bool
writeHierarchy)
{
+ if (TableName == "") {
+ throw new InvalidOperationException ("Cannot
serialize the DataTable. DataTable name is not set.");
+ }
if (writeHierarchy == false) {
WriteXmlSchema (writer);
}
@@ -2566,11 +2599,31 @@
}
writer.WriteStartDocument ();
//XmlSchemaWriter.WriteXmlSchema (ds,
writer);
- DataTable [] tables = new DataTable
[ds.Tables.Count];
- DataRelation [] relations = new
DataRelation [ds.Relations.Count];
- for (int i = 0; i < ds.Tables.Count;
i++) tables[i] = ds.Tables[i];
- for (int i = 0; i < ds.Relations.Count;
i++) relations[i] = ds.Relations[i];
- XmlSchemaWriter.WriteXmlSchema (writer,
tables, relations, TableName, ds.DataSetName);
+ //DataTable [] tables = new DataTable
[ds.Tables.Count];
+ DataTable [] tables = null;
+ //DataRelation [] relations = new
DataRelation [ds.Relations.Count];
+ //for (int i = 0; i <
ds.Relations.Count; i++) {
+ // relations[i] = ds.Relations[i];
+ //}
+ DataRelation [] relations = null;
+ if (ChildRelations.Count > 0) {
+ relations = new DataRelation
[ChildRelations.Count];
+ for (int i = 0; i <
ChildRelations.Count; i++) {
+ relations [i] =
ChildRelations [i];
+ }
+ tables = new DataTable
[ds.Tables.Count];
+ for (int i = 0; i <
ds.Tables.Count; i++) tables [i] = ds.Tables [i];
+ } else {
+ tables = new DataTable [1];
+ tables [0] = this;
+ }
+
+ string tableName;
+ if (ds.Namespace == "")
+ tableName = TableName;
+ else
+ tableName = ds.Namespace +
"_x003A_" + TableName;
+ XmlSchemaWriter.WriteXmlSchema (writer,
tables, relations, tableName, ds.DataSetName);
} finally {
if (tmp != null)
ds.Tables.Remove (this);
@@ -2580,6 +2633,12 @@
public void WriteXmlSchema (string fileName, bool
writeHierarchy)
{
+ if (fileName == "") {
+ throw new ArgumentException ("Empty path name
is not legal.");
+ }
+ if (TableName == "") {
+ throw new InvalidOperationException ("Cannot
serialize the DataTable. DataTable name is not set.");
+ }
XmlWriter xw = null;
try {
XmlWriterSettings s = GetWriterSettings ();
Modified: trunk/mcs/class/System.Data/System.Data/XmlSchemaWriter.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/XmlSchemaWriter.cs 2006-11-28
05:37:13 UTC (rev 68562)
+++ trunk/mcs/class/System.Data/System.Data/XmlSchemaWriter.cs 2006-11-28
06:32:38 UTC (rev 68563)
@@ -213,7 +213,7 @@
if (dataSetLocale == CultureInfo.CurrentCulture) {
w.WriteAttributeString (
XmlConstants.MsdataPrefix,
- "UseCurrentCulture",
+ "UseCurrentLocale",
XmlConstants.MsdataNamespace,
"true");
}
@@ -231,6 +231,7 @@
w.WriteStartElement ("xs", "complexType", xmlnsxs);
w.WriteStartElement ("xs", "choice", xmlnsxs);
+ w.WriteAttributeString ("minOccurs", "0");
w.WriteAttributeString ("maxOccurs", "unbounded");
foreach (DataTable table in tables) {
@@ -336,11 +337,12 @@
ForeignKeyConstraint fk = c as
ForeignKeyConstraint;
bool haveConstraint = false;
- if (relations != null)
+ if (relations != null) {
foreach (DataRelation r in
relations)
- if(r.RelationName ==
fk.ConstraintName)
+ if (r.RelationName ==
fk.ConstraintName)
haveConstraint
= true;
- if (fk != null && !haveConstraint) {
+ }
+ if (tables.Length > 1 && fk != null &&
!haveConstraint) {
DataRelation rel = new
DataRelation (fk.ConstraintName,
fk.RelatedColumns, fk.Columns);
AddForeignKeys (rel, names,
true);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches