All pastes #710319 Raw Edit

Varadhan

public text v1 · immutable
#710319 ·published 2007-09-25 12:53 UTC
rendered paste body
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlInt16.cs        2007-09-25 10:50:13 UTC (rev 86306)
+++ trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlInt16.cs        2007-09-25 11:09:37 UTC (rev 86307)
@@ -42,6 +42,7 @@
 #if NET_2_0
        [SerializableAttribute]
        [XmlSchemaProvider ("GetXsdType")]
+       [XmlRootAttribute ("short")]
 #endif
        public struct SqlInt16 : INullable, IComparable
 #if NET_2_0
@@ -491,17 +492,43 @@
                {
                        throw new NotImplementedException ();
                }
-               
-               [MonoTODO]
+       
                void IXmlSerializable.ReadXml (XmlReader reader)
-               {
-                       throw new NotImplementedException ();
+               {                       
+                       if (reader == null)
+                               return;
+
+                       switch (reader.ReadState) {
+                       case ReadState.EndOfFile:
+                       case ReadState.Error:
+                       case ReadState.Closed:
+                               return;
+                       }
+                       // Skip XML declaration and prolog
+                       // or do I need to validate for the <SqlInt16> tag?
+                       reader.MoveToContent ();
+                       if (reader.EOF)
+                               return;
+                       
+                       reader.Read ();
+                       if (reader.NodeType == XmlNodeType.EndElement)
+                               return;
+
+                       if (reader.Value.Length > 0) {
+                               if (String.Compare ("Null", reader.Value) == 0) {
+                                       // means a null reference/invalid value
+                                       notNull = false;
+                                       return; 
+                               }
+                               // FIXME: Validate the value for expected format
+                               this.value = Int16.Parse (reader.Value);
+                               this.notNull = true;
+                       }
                }
                
-               [MonoTODO]
                void IXmlSerializable.WriteXml (XmlWriter writer) 
                {
-                       throw new NotImplementedException ();
+                       writer.WriteString (this.ToString ());
                }
 #endif
                #endregion