Author: atsushi
Date: 2008-01-30 02:17:03 -0500 (Wed, 30 Jan 2008)
New Revision: 94362

Modified:
   
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonReader.cs
   
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/JsonReaderTest.cs
Log:
2008-01-30  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * JsonReader.cs : GetAttribute() was not still missing support for
          __type.

        * JsonReaderTest.cs : test GetAttribute() for "__type".



Modified: 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog
       2008-01-30 06:24:52 UTC (rev 94361)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog
       2008-01-30 07:17:03 UTC (rev 94362)
@@ -1,5 +1,10 @@
 2008-01-30  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * JsonReader.cs : GetAttribute() was not still missing support for
+         __type.
+
+2008-01-30  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * JsonReader.cs : now __type is fully supported in every methods and
          properties in correct shape.
 

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonReader.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonReader.cs
   2008-01-30 06:24:52 UTC (rev 94361)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonReader.cs
   2008-01-30 07:17:03 UTC (rev 94362)
@@ -252,23 +252,33 @@
 
                public override string GetAttribute (int index)
                {
-                       if (index == 0 && AttributeCount == 1)
+                       if (index == 0 && current_node == XmlNodeType.Element)
                                return elements.Peek ().Type;
-                       throw new ArgumentOutOfRangeException ("index", "Index 
is must be 0 and only valid on an element on this XmlDictionaryReader");
+                       else if (index == 1 && current_runtime_type != null)
+                               return current_runtime_type;
+                       throw new ArgumentOutOfRangeException ("index", "Index 
is must be either 0 or 1 when there is an explicit __type in the object, and 
only valid on an element on this XmlDictionaryReader");
                }
 
                public override string GetAttribute (string name)
                {
-                       if (current_node == XmlNodeType.Element && name == 
"type")
+                       if (current_node != XmlNodeType.Element)
+                               return null;
+                       switch (name) {
+                       case "type":
                                return elements.Peek ().Type;
-                       return null;
+                       case "__type":
+                               return current_runtime_type;
+                       default:
+                               return null;
+                       }
                }
 
                public override string GetAttribute (string localName, string 
ns)
                {
-                       if (current_node == XmlNodeType.Element && localName == 
"type" && ns == String.Empty)
-                               return elements.Peek ().Type;
-                       return null;
+                       if (ns == String.Empty)
+                               return GetAttribute (localName);
+                       else
+                               return null;
                }
 
                public override string LookupNamespace (string prefix)

Modified: 
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/ChangeLog
  2008-01-30 06:24:52 UTC (rev 94361)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/ChangeLog
  2008-01-30 07:17:03 UTC (rev 94362)
@@ -1,5 +1,9 @@
 2008-01-30  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * JsonReaderTest.cs : test GetAttribute() for "__type".
+
+2008-01-30  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * JsonReaderTest.cs : added tests for "__type" attributes (some of
          them are not working yet).
 

Modified: 
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/JsonReaderTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/JsonReaderTest.cs
  2008-01-30 06:24:52 UTC (rev 94361)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/JsonReaderTest.cs
  2008-01-30 07:17:03 UTC (rev 94362)
@@ -787,5 +787,19 @@
                        Assert.IsFalse (r.MoveToAttribute ("__type"));
                        r.Skip ();
                }
+
+               [Test]
+               public void ReadObjectRuntimeTypeInArray ()
+               {
+                       XmlReader r = CreateReader 
(@"[{""__type"":""DCWithEnum:#MonoTests.System.Runtime.Serialization.Json"",""_colors"":0}]");
+                       r.Read ();
+                       Assert.AreEqual ("root", r.LocalName, "#1-1");
+                       Assert.AreEqual ("array", r.GetAttribute ("type"), 
"#1-2");
+                       r.Read ();
+                       Assert.AreEqual ("item", r.LocalName, "#2-1");
+                       Assert.AreEqual ("object", r.GetAttribute ("type"), 
"#2-2");
+                       Assert.IsNotNull (r.GetAttribute ("__type"), "#2-3");
+                       r.Read ();
+               }
        }
 }
\ No newline at end of file

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to