using System.IO;\r
using System.Data;\r
using System.Xml;\r
+using System.Xml.Serialization;\r
\r
\r
namespace System.Data\r
\r
// No need to check DataSetName. In fact, it is ignored.\r
\r
- bool ambiguous = false;\r
DataTable dt = dataset.Tables [local];\r
if (dt == null)\r
return true;\r
// Consume attributes\r
if (reader.MoveToFirstAttribute ()) {\r
do {\r
- if (reader.NamespaceURI == XmlConstants.XmlnsNS)\r
+ if (reader.NamespaceURI == XmlConstants.XmlnsNS\r
+#if NET_2_0\r
+ || reader.NamespaceURI == XmlConstants.XmlNS\r
+#endif\r
+ )\r
continue;\r
ReadElementAttribute (row);\r
} while (reader.MoveToNextAttribute ());\r
\r
bool wasEmpty = reader.IsEmptyElement;\r
int depth = reader.Depth;\r
- row [col] = StringToObject (col.DataType, reader.ReadElementString ());\r
+\r
+ if (typeof (IXmlSerializable).IsAssignableFrom (col.DataType)) {\r
+#if NET_2_0\r
+ try {\r
+ // NOTE: ReadElementString works fine with proper XML with CDATA etc,\r
+ // however doesn't behave well with XMLs like the one in \r
+ // https://bugzilla.novell.com/show_bug.cgi?id=377146 which is \r
+ // apparently supported by MS.NET - to maintain compatibility,\r
+ // Try reading the element content as an object type\r
+ row [col] = reader.ReadContentAsObject ();\r
+ } catch {\r
+#endif\r
+ // XML is not in accordance to expected standards, try reading the content as an xml doc\r
+ row [col] = reader.ReadInnerXml ();\r
+#if NET_2_0\r
+ }\r
+#endif\r
+ } else {\r
+ row [col] = StringToObject (col.DataType, reader.ReadElementString ());\r
+ }\r
+ \r
if (!wasEmpty && reader.Depth > depth) {\r
// This means, instance does not match with\r
// the schema (because the instance element\r
if (type == typeof (TimeSpan)) return XmlConvert.ToTimeSpan (value);\r
if (type == typeof (Guid)) return XmlConvert.ToGuid (value);\r
if (type == typeof (byte[])) return Convert.FromBase64String (value);\r
+ if (type == typeof (System.Type)) return System.Type.GetType (value);\r
\r
return Convert.ChangeType (value, type);\r
}\r