Author: atsushi
Date: 2007-09-01 13:19:18 -0400 (Sat, 01 Sep 2007)
New Revision: 85169

Added:
   trunk/olive/class/System.ServiceModel.Web/Assembly/ChangeLog
   trunk/olive/class/System.ServiceModel.Web/System.Xml/
   trunk/olive/class/System.ServiceModel.Web/System.Xml/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonReaderWriterFactory.cs
   trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonWriter.cs
   trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/
   trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/ChangeLog
   trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/JsonWriterTest.cs
Modified:
   trunk/olive/class/System.ServiceModel.Web/
   trunk/olive/class/System.ServiceModel.Web/Assembly/AssemblyInfo.cs
   trunk/olive/class/System.ServiceModel.Web/ChangeLog
   trunk/olive/class/System.ServiceModel.Web/Makefile
   trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
Log:
2007-09-01  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * System.ServiceModel.Web_test.dll.sources : removed all old tests
          for obsoleted types. They must be updated before being added so
          that they do not block run-test-ondotnet. Added JsonWriterTest.cs.
        * System.ServiceModel.Web.dll.sources : added JsonWriter.cs and
          JsonReaderWriterFactory.cs.
        * Makefile : fixed version number. It is not NO_TEST anymore.

        * AssemblyInfo.cs : updated version and key.

        * JsonWriter.cs,
          JsonReaderWriterFactory.cs : new files.

        * JsonWriterTest.cs : initial checkin.




Property changes on: trunk/olive/class/System.ServiceModel.Web
___________________________________________________________________
Name: svn:ignore
   + TestResult-net_3_5.log
TestResult-net_3_5.xml
TestResult-ondotnet-net_3_5.log
TestResult-ondotnet-net_3_5.xml
System.ServiceModel.Web_test_net_3_5.dll
System.ServiceModel.Web_test_net_3_5.dll.mdb


Modified: trunk/olive/class/System.ServiceModel.Web/Assembly/AssemblyInfo.cs
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/Assembly/AssemblyInfo.cs  
2007-09-01 17:07:41 UTC (rev 85168)
+++ trunk/olive/class/System.ServiceModel.Web/Assembly/AssemblyInfo.cs  
2007-09-01 17:19:18 UTC (rev 85169)
@@ -48,10 +48,10 @@
 
 [assembly: CLSCompliant (true)]
 [assembly: AssemblyDefaultAlias ("System.ServiceModel.Web.dll")]
-[assembly: AssemblyInformationalVersion ("0.0.0.1")]
+[assembly: AssemblyInformationalVersion ("3.5.0.0")]
 [assembly: NeutralResourcesLanguage ("en-US")]
 
 [assembly: ComVisible (false)]
 
 [assembly: AssemblyDelaySign (true)]
-[assembly: AssemblyKeyFile("../winfx.pub")]
+[assembly: AssemblyKeyFile("../orcas.pub")]

Added: trunk/olive/class/System.ServiceModel.Web/Assembly/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/Assembly/ChangeLog        
2007-09-01 17:07:41 UTC (rev 85168)
+++ trunk/olive/class/System.ServiceModel.Web/Assembly/ChangeLog        
2007-09-01 17:19:18 UTC (rev 85169)
@@ -0,0 +1,3 @@
+2007-09-01  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * AssemblyInfo.cs : updated version and key.

Modified: trunk/olive/class/System.ServiceModel.Web/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/ChangeLog 2007-09-01 17:07:41 UTC 
(rev 85168)
+++ trunk/olive/class/System.ServiceModel.Web/ChangeLog 2007-09-01 17:19:18 UTC 
(rev 85169)
@@ -1,3 +1,12 @@
+2007-09-01  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * System.ServiceModel.Web_test.dll.sources : removed all old tests
+         for obsoleted types. They must be updated before being added so
+         that they do not block run-test-ondotnet. Added JsonWriterTest.cs.
+       * System.ServiceModel.Web.dll.sources : added JsonWriter.cs and
+         JsonReaderWriterFactory.cs.
+       * Makefile : fixed version number. It is not NO_TEST anymore.
+
 2007-06-07  Joel Reed  <[EMAIL PROTECTED]>
 
        * ATOM: serialize generator, logo, copyrights, and language

Modified: trunk/olive/class/System.ServiceModel.Web/Makefile
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/Makefile  2007-09-01 17:07:41 UTC 
(rev 85168)
+++ trunk/olive/class/System.ServiceModel.Web/Makefile  2007-09-01 17:19:18 UTC 
(rev 85169)
@@ -9,17 +9,16 @@
 
 EXTRA_DISTFILES = $(RESOURCE_FILES)
 
-# This is a WinFX only assembly
+# This is a Orcas only assembly
 VALID_PROFILE := $(filter net_3_5, $(PROFILE))
 ifndef VALID_PROFILE
 LIBRARY_NAME = dummy-System.ServiceModel.Web.dll
 NO_INSTALL = yes
 NO_SIGN_ASSEMBLY = yes
-NO_TEST = yes
 endif
 
 test-data-ondotnet:
-       csc -out:SyndicationSerializerUtil.exe 
-r:../lib/net_3_0/System.ServiceModel.Web.dll $(LIB_MCS_FLAGS) 
Test\\System.ServiceModel.Syndication\\SyndicationSerializerUtil.cs 
Test\\System.ServiceModel.Syndication\\FeedLib.cs
+       csc -out:SyndicationSerializerUtil.exe 
-r:../lib/net_3_5/System.ServiceModel.Web.dll $(LIB_MCS_FLAGS) 
Test\\System.ServiceModel.Syndication\\SyndicationSerializerUtil.cs 
Test\\System.ServiceModel.Syndication\\FeedLib.cs
        ./SyndicationSerializerUtil.exe
 
 test-data:

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources   
    2007-09-01 17:07:41 UTC (rev 85168)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources   
    2007-09-01 17:19:18 UTC (rev 85169)
@@ -2,20 +2,22 @@
 ../../build/common/Locale.cs
 ../../build/common/MonoTODOAttribute.cs
 Assembly/AssemblyInfo.cs
-System.ServiceModel.Syndication/SyndicationFeed.cs
-System.ServiceModel.Syndication/SyndicationItem.cs
 System.ServiceModel.Syndication/Atom10Serializer.cs
-System.ServiceModel.Syndication/TextSyndicationContent.cs
+System.ServiceModel.Syndication/Rss20Serializer.cs
+System.ServiceModel.Syndication/SyndicationCategory.cs
 System.ServiceModel.Syndication/SyndicationContent.cs
-System.ServiceModel.Syndication/TextSyndicationContentKind.cs
-System.ServiceModel.Syndication/SyndicationSerializer.cs
-System.ServiceModel.Syndication/Rss20Serializer.cs
-System.ServiceModel.Syndication/SyndicationLink.cs
-System.ServiceModel.Syndication/SyndicationElementExtension.cs         
+System.ServiceModel.Syndication/SyndicationElementExtension.cs
 System.ServiceModel.Syndication/SyndicationElementExtensionCollection.cs
 System.ServiceModel.Syndication/SyndicationElementExtensionKind.cs
+System.ServiceModel.Syndication/SyndicationFeed.cs
+System.ServiceModel.Syndication/SyndicationItem.cs
+System.ServiceModel.Syndication/SyndicationLink.cs
 System.ServiceModel.Syndication/SyndicationPerson.cs
+System.ServiceModel.Syndication/SyndicationSerializer.cs
 System.ServiceModel.Syndication/SyndicationVersion.cs
+System.ServiceModel.Syndication/TextSyndicationContent.cs
+System.ServiceModel.Syndication/TextSyndicationContentKind.cs
 System.ServiceModel.Syndication/UrlSyndicationContent.cs
 System.ServiceModel.Syndication/XmlSyndicationContent.cs
-System.ServiceModel.Syndication/SyndicationCategory.cs
+System.Xml/JsonReaderWriterFactory.cs
+System.Xml/JsonWriter.cs

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2007-09-01 17:07:41 UTC (rev 85168)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2007-09-01 17:19:18 UTC (rev 85169)
@@ -1,6 +1 @@
-System.ServiceModel.Syndication/SyndicationFeedTest.cs
-System.ServiceModel.Syndication/SyndicationItemTest.cs
-System.ServiceModel.Syndication/FeedLib.cs
-System.ServiceModel.Syndication/Atom10SerializerTest.cs
-System.ServiceModel.Syndication/SyndicationContentTest.cs
-System.ServiceModel.Syndication/Rss20SerializerTest.cs
+System.Xml/JsonWriterTest.cs

Added: trunk/olive/class/System.ServiceModel.Web/System.Xml/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System.Xml/ChangeLog      
2007-09-01 17:07:41 UTC (rev 85168)
+++ trunk/olive/class/System.ServiceModel.Web/System.Xml/ChangeLog      
2007-09-01 17:19:18 UTC (rev 85169)
@@ -0,0 +1,4 @@
+2007-09-01  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * JsonWriter.cs,
+         JsonReaderWriterFactory.cs : new files.

Added: 
trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonReaderWriterFactory.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonReaderWriterFactory.cs 
    2007-09-01 17:07:41 UTC (rev 85168)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonReaderWriterFactory.cs 
    2007-09-01 17:19:18 UTC (rev 85169)
@@ -0,0 +1,78 @@
+//
+// JsonReaderWriterFactory.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+       public static class JsonReaderWriterFactory
+       {
+               public static XmlDictionaryReader CreateJsonReader (byte [] 
source, XmlDictionaryReaderQuotas quotas)
+               {
+                       return CreateJsonReader (source, 0, source.Length, 
quotas);
+               }
+
+               public static XmlDictionaryReader CreateJsonReader (byte [] 
source, int offset, int length, XmlDictionaryReaderQuotas quotas)
+               {
+                       return CreateJsonReader (source, offset, length, 
Encoding.UTF8, quotas, null);
+               }
+
+               [MonoTODO]
+               public static XmlDictionaryReader CreateJsonReader (byte [] 
source, int offset, int length, Encoding encoding, XmlDictionaryReaderQuotas 
quotas, OnXmlDictionaryReaderClose readerClose)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlDictionaryReader CreateJsonReader (Stream 
source, XmlDictionaryReaderQuotas quotas)
+               {
+                       return CreateJsonReader (source, Encoding.UTF8, quotas, 
null);
+               }
+
+               [MonoTODO]
+               public static XmlDictionaryReader CreateJsonReader (Stream 
source, Encoding encoding, XmlDictionaryReaderQuotas quotas, 
OnXmlDictionaryReaderClose readerClose)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlDictionaryWriter CreateJsonWriter (Stream 
stream)
+               {
+                       return CreateJsonWriter (stream, new UTF8Encoding 
(false, true));
+               }
+
+               public static XmlDictionaryWriter CreateJsonWriter (Stream 
stream, Encoding encoding)
+               {
+                       return CreateJsonWriter (stream, encoding, false);
+               }
+
+               public static XmlDictionaryWriter CreateJsonWriter (Stream 
stream, Encoding encoding, bool closeOutput)
+               {
+                       return new JsonWriter (stream, encoding, closeOutput);
+               }
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonReaderWriterFactory.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonWriter.cs
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonWriter.cs  
2007-09-01 17:07:41 UTC (rev 85168)
+++ trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonWriter.cs  
2007-09-01 17:19:18 UTC (rev 85169)
@@ -0,0 +1,463 @@
+//
+// JsonWriter.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using System.Xml;
+
+namespace System.Xml
+{
+       class JsonWriter : XmlDictionaryWriter
+       {
+               enum ElementType
+               {
+                       None,
+                       Object,
+                       Array,
+                       String,
+                       Number,
+                       Boolean,
+               }
+
+               StreamWriter output;
+               bool close_output;
+               WriteState state;
+               Stack<ElementType> element_kinds = new Stack<ElementType> ();
+               Stack<bool> first_content_flags = new Stack<bool> ();
+               string attr_value;
+
+               public JsonWriter (Stream stream, Encoding encoding, bool 
closeOutput)
+               {
+                       output = new StreamWriter (stream, encoding);
+               }
+
+               void CheckState ()
+               {
+                       switch (state) {
+                       case WriteState.Closed:
+                       case WriteState.Error:
+                               throw new InvalidOperationException 
(String.Format ("This XmlDictionaryReader is already at '{0}' state", state));
+                       }
+               }
+
+               // copied from System.Silverlight JavaScriptSerializer.
+               static string EscapeStringLiteral (string input)
+               {
+                       StringBuilder sb = null;
+                       int i = 0, start = 0;
+                       for (; i < input.Length; i++) {
+                               switch (input [i]) {
+                               case '"':
+                                       AppendBuffer (ref sb, input, start, i, 
@"\""");
+                                       break;
+                               case '\\':
+                                       AppendBuffer (ref sb, input, start, i, 
@"\\");
+                                       break;
+                               //case '/':
+                               //      AppendBuffer (ref sb, input, start, i, 
@"\/");
+                               //      break;
+                               case '\x8':
+                                       AppendBuffer (ref sb, input, start, i, 
@"\b");
+                                       break;
+                               case '\f':
+                                       AppendBuffer (ref sb, input, start, i, 
@"\f");
+                                       break;
+                               case '\n':
+                                       AppendBuffer (ref sb, input, start, i, 
/*@"\n"*/@"\u000a");
+                                       break;
+                               case '\r':
+                                       AppendBuffer (ref sb, input, start, i, 
/*@"\r"*/@"\u000d");
+                                       break;
+                               case '\t':
+                                       AppendBuffer (ref sb, input, start, i, 
/*@"\t"*/@"\u0009");
+                                       break;
+                               default:
+                                       continue;
+                               }
+                               start = i + 1;
+                       }
+                       string remaining = input.Substring (start, i - start);
+                       if (sb != null)
+                               return sb.Append (remaining).ToString ();
+                       else
+                               return remaining;
+               }
+
+               static void AppendBuffer (ref StringBuilder sb, string input, 
int start, int i, string append)
+               {
+                       if (sb == null)
+                               sb = new StringBuilder ();
+                       if (i != start)
+                               sb.Append (input, start, i - start);
+                       sb.Append (append);
+               }
+
+               public override WriteState WriteState {
+                       get { return state; }
+               }
+
+               public override void Close ()
+               {
+                       // close all open elements
+                       while (element_kinds.Count > 0)
+                               WriteEndElement ();
+
+                       if (close_output)
+                               output.Close ();
+                       else
+                               output.Flush ();
+
+                       state = WriteState.Closed;
+               }
+
+               public override void Flush ()
+               {
+                       output.Flush ();
+               }
+
+               public override void WriteStartElement (string prefix, string 
localName, string ns)
+               {
+                       CheckState ();
+
+                       if (localName == null)
+                               throw new ArgumentNullException ("localName");
+                       else if (localName.Length == 0)
+                               throw new ArgumentException ("Empty string is 
not a valid localName in this XmlDictionaryWriter");
+
+                       if (!String.IsNullOrEmpty (ns))
+                               throw new ArgumentException ("Non-empty 
namespace URI is not allowed in this XmlDictionaryWriter");
+                       if (!String.IsNullOrEmpty (prefix))
+                               throw new ArgumentException ("Non-empty prefix 
is not allowed in this XmlDictionaryWriter");
+
+                       if (state == WriteState.Attribute)
+                               WriteEndAttribute ();
+                       if (state == WriteState.Element)
+                               CloseStartElement ();
+
+                       else if (state != WriteState.Start && 
element_kinds.Count == 0)
+                               throw new XmlException ("This 
XmlDictionaryWriter does not support multiple top-level elements");
+
+                       if (element_kinds.Count == 0) {
+                               if (localName != "root")
+                                       throw new XmlException ("Only 'root' is 
allowed for the name of the top-level element");
+                       } else {
+                               switch (element_kinds.Peek ()) {
+                               case ElementType.Array:
+                                       if (localName != "item")
+                                               throw new XmlException ("Only 
'item' is allowed as a content element of an array");
+                                       break;
+                               case ElementType.String:
+                                       throw new XmlException ("Mixed content 
is not allowed in this XmlDictionaryWriter");
+                               case ElementType.None:
+                                       throw new XmlException ("Before writing 
a child element, an element needs 'type' attribute to indicate whether the 
element is a JSON array or a JSON object in this XmlDictionaryWriter");
+                               }
+
+                               if (first_content_flags.Peek ()) {
+                                       first_content_flags.Pop ();
+                                       first_content_flags.Push (false);
+                               }
+                               else
+                                       output.Write (',');
+
+                               if (element_kinds.Peek () != ElementType.Array) 
{
+                                       output.Write ('"');
+                                       output.Write (localName);
+                                       output.Write ("\":");
+                               }
+                       }
+
+                       element_kinds.Push (ElementType.None); // undetermined 
yet
+
+                       state = WriteState.Element;
+               }
+
+               public override void WriteEndElement ()
+               {
+                       CheckState ();
+
+                       if (state == WriteState.Attribute)
+                               throw new XmlException ("Cannot end element 
when an attribute is being written");
+                       if (state == WriteState.Element)
+                               CloseStartElement ();
+
+                       if (element_kinds.Count == 0)
+                               throw new XmlException ("There is no open 
element to close");
+                       switch (element_kinds.Pop ()) {
+                       case ElementType.String:
+                               output.Write ('"');
+                               break;
+                       case ElementType.Array:
+                               output.Write (']');
+                               break;
+                       case ElementType.Object:
+                               output.Write ('}');
+                               break;
+                       }
+
+                       // not sure if it is correct though ...
+                       state = WriteState.Content;
+                       first_content_flags.Pop ();
+               }
+
+               public override void WriteFullEndElement ()
+               {
+                       WriteEndElement (); // no such difference in JSON.
+               }
+
+               public override void WriteStartAttribute (string prefix, string 
localName, string ns)
+               {
+                       CheckState ();
+
+                       if (state != WriteState.Element)
+                               throw new XmlException ("Cannot write attribute 
as this XmlDictionaryWriter is not at element state");
+
+                       if (!String.IsNullOrEmpty (ns))
+                               throw new ArgumentException ("Non-empty 
namespace URI is not allowed in this XmlDictionaryWriter");
+                       if (!String.IsNullOrEmpty (prefix))
+                               throw new ArgumentException ("Non-empty prefix 
is not allowed in this XmlDictionaryWriter");
+
+                       if (localName != "type")
+                               throw new ArgumentException ("Only 'type' 
attribute is allowed in this XmlDictionaryWriter");
+
+                       if (state != WriteState.Element)
+                               throw new InvalidOperationException 
(String.Format ("Attribute cannot be written in {0} mode", state));
+
+                       state = WriteState.Attribute;
+               }
+
+               public override void WriteEndAttribute ()
+               {
+                       CheckState ();
+
+                       if (state != WriteState.Attribute)
+                               throw new XmlException ("Cannot close 
attribute, as this XmlDictionaryWriter is not at attribute state");
+
+                       switch (attr_value) {
+                       case "object":
+                               element_kinds.Pop ();
+                               element_kinds.Push (ElementType.Object);
+                               output.Write ('{');
+                               break;
+                       case "array":
+                               element_kinds.Pop ();
+                               element_kinds.Push (ElementType.Array);
+                               output.Write ('[');
+                               break;
+                       case "number":
+                               element_kinds.Pop ();
+                               element_kinds.Push (ElementType.Number);
+                               break;
+                       case "boolean":
+                               element_kinds.Pop ();
+                               element_kinds.Push (ElementType.Boolean);
+                               break;
+                       case "string":
+                               element_kinds.Pop ();
+                               element_kinds.Push (ElementType.String);
+                               break;
+                       default:
+                               throw new XmlException (String.Format 
("Unexpected type attribute value '{0}'", attr_value));
+                       }
+
+                       state = WriteState.Element;
+                       attr_value = null;
+               }
+
+               void CloseStartElement ()
+               {
+                       if (element_kinds.Peek () == ElementType.None) {
+                               element_kinds.Pop ();
+                               element_kinds.Push (ElementType.String);
+                       }
+
+                       if (element_kinds.Peek () == ElementType.String)
+                               output.Write ('"');
+
+                       first_content_flags.Push (true);
+               }
+
+               public override void WriteString (string text)
+               {
+                       CheckState ();
+
+                       if (state == WriteState.Start)
+                               throw new InvalidOperationException ("Top-level 
content string is not allowed in this XmlDictionaryWriter");
+
+                       if (state == WriteState.Element) {
+                               CloseStartElement ();
+                               state = WriteState.Content;
+                       }
+
+                       if (state == WriteState.Attribute)
+                               attr_value += text;
+                       else {
+                               switch (element_kinds.Peek ()) {
+                               case ElementType.String:
+                               case ElementType.Number:
+                               case ElementType.Boolean:
+                                       break;
+                               default:
+                                       throw new XmlException (String.Format 
("Simple content string is allowed only for string, number and boolean types 
and not for {0} type", element_kinds.Peek ()));
+                               }
+
+                               output.Write (EscapeStringLiteral (text));
+                       }
+               }
+
+               #region mostly-ignored operations
+
+               public override string LookupPrefix (string ns)
+               {
+                       // Since there is no way to declare namespaces in
+                       // this writer, it always returns fixed results.
+                       if (ns == null)
+                               throw new ArgumentNullException ("ns");
+                       else if (ns.Length == 0)
+                               return String.Empty;
+                       else if (ns == "http://www.w3.org/2000/xmlns/";)
+                               return "xmlns";
+                       else if (ns == "http://www.w3.org/XML/1998/namespace";)
+                               return "xml";
+                       return null;
+               }
+
+               public override void WriteStartDocument ()
+               {
+                       CheckState ();
+               }
+
+               public override void WriteStartDocument (bool standalone)
+               {
+                       CheckState ();
+               }
+
+               public override void WriteEndDocument ()
+               {
+                       CheckState ();
+               }
+
+               #endregion
+
+               #region unsupported operations
+
+               public override void WriteDocType (string name, string pubid, 
string sysid, string intSubset)
+               {
+                       CheckState ();
+
+                       throw new NotSupportedException ("This 
XmlDictionaryWriter does not support writing doctype declaration");
+               }
+
+               public override void WriteComment (string text)
+               {
+                       CheckState ();
+
+                       throw new NotSupportedException ("This 
XmlDictionaryWriter does not support writing comment");
+               }
+
+               public override void WriteEntityRef (string text)
+               {
+                       CheckState ();
+
+                       throw new NotSupportedException ("This 
XmlDictionaryWriter does not support writing entity reference");
+               }
+
+               public override void WriteProcessingInstruction (string target, 
string data)
+               {
+                       CheckState ();
+
+                       if (String.Compare (target, "xml", 
StringComparison.OrdinalIgnoreCase) != 0)
+                               throw new ArgumentException ("This 
XmlDictionaryWriter does not support writing processing instruction");
+               }
+
+               #endregion
+
+               #region WriteString() variants
+
+               public override void WriteRaw (string text)
+               {
+                       WriteString (text);
+               }
+
+               public override void WriteRaw (char [] chars, int start, int 
length)
+               {
+                       WriteChars (chars, start, length);
+               }
+
+               public override void WriteCData (string text)
+               {
+                       WriteString (text);
+               }
+
+               public override void WriteCharEntity (char entity)
+               {
+                       WriteString (entity.ToString ());
+               }
+
+               public override void WriteChars (char [] chars, int start, int 
length)
+               {
+                       WriteString (new string (chars, start, length));
+               }
+
+               public override void WriteSurrogateCharEntity (char high, char 
low)
+               {
+                       WriteChars (new char [] {high, low}, 0, 2);
+               }
+
+               public override void WriteBase64 (byte [] bytes, int start, int 
length)
+               {
+                       WriteString (Convert.ToBase64String (bytes, start, 
length));
+               }
+
+               public override void WriteWhitespace (string text)
+               {
+                       if (text == null)
+                               throw new ArgumentNullException ("text");
+                       for (int i = 0; i < text.Length; i++) {
+                               if (text [i] != ' ') {
+                                       for (int j = i; j < text.Length; j++) {
+                                               switch (text [j]) {
+                                               case '\t':
+                                               case ' ':
+                                               case '\n':
+                                               case '\r':
+                                                       continue;
+                                               default:
+                                                       throw new 
ArgumentException (String.Format ("WriteWhitespace() does not accept 
non-whitespace character '{0}'", text [j]));
+                                               }
+                                       }
+                                       break;
+                               }
+                       }
+                       WriteString (text);
+               }
+
+               #endregion
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/System.Xml/JsonWriter.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/ChangeLog 
2007-09-01 17:07:41 UTC (rev 85168)
+++ trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/ChangeLog 
2007-09-01 17:19:18 UTC (rev 85169)
@@ -0,0 +1,3 @@
+2007-09-01  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * JsonWriterTest.cs : initial checkin.

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/JsonWriterTest.cs
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/JsonWriterTest.cs 
2007-09-01 17:07:41 UTC (rev 85168)
+++ trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/JsonWriterTest.cs 
2007-09-01 17:19:18 UTC (rev 85169)
@@ -0,0 +1,574 @@
+//
+// JsonWriterTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Text;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+       [TestFixture]
+       public class JsonWriterTest
+       {
+               MemoryStream ms;
+               XmlDictionaryWriter w;
+
+               string ResultString {
+                       get { return Encoding.UTF8.GetString (ms.ToArray ()); }
+               }
+
+               [SetUp]
+               public void Setup ()
+               {
+                       ms = new MemoryStream ();
+                       w = JsonReaderWriterFactory.CreateJsonWriter (ms);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullStream ()
+               {
+                       JsonReaderWriterFactory.CreateJsonWriter (null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullEncoding ()
+               {
+                       JsonReaderWriterFactory.CreateJsonWriter (new 
MemoryStream (), null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void SimpleElementNotRoot ()
+               {
+                       w.WriteStartElement ("foo");
+               }
+
+               [Test]
+               public void SimpleElement ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteEndElement ();
+                       w.Close ();
+                       // empty string literal ("")
+                       Assert.AreEqual ("\"\"", ResultString, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void SimpleElement2 ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartElement ("foo");
+                       // type='array' or type='object' is required before 
writing immediate child of an element.
+               }
+
+               [Test]
+               public void SimpleElement3 ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteStartElement ("e1");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteStartElement ("e1_1");
+                       w.WriteEndElement (); // treated as a string literal
+                       w.WriteEndElement ();
+                       w.WriteStartElement ("e2");
+                       w.WriteString ("value");
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+                       w.Close ();
+                       string json = 
"{\"e1\":{\"e1_1\":\"\"},\"e2\":\"value\"}";
+                       Assert.AreEqual (json, ResultString, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void AttributeNonType ()
+               {
+                       w.WriteStartElement ("root");
+                       // only "type" attribute is expected.
+                       w.WriteStartAttribute ("a1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void TypeAttributeNonStandard ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "foo");
+               }
+
+               [Test]
+               public void SimpleTypeAttribute ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "number");
+                       w.WriteEndElement ();
+                       w.Close ();
+                       Assert.AreEqual (String.Empty, ResultString, "#1");
+               }
+
+               [Test]
+               public void SimpleTypeAttribute2 ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteStartElement ("foo");
+                       w.WriteAttributeString ("type", "number");
+                       w.WriteString ("1");
+                       w.WriteEndElement ();
+                       w.Close ();
+                       Assert.AreEqual ("{\"foo\":1}", ResultString, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteStringForNull ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartElement ("foo");
+                       w.WriteAttributeString ("type", "null");
+                       w.WriteString ("1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteStringForArray ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteStartElement ("foo");
+                       w.WriteAttributeString ("type", "array");
+                       w.WriteString ("1");
+               }
+
+               [Test]
+               // uh, no exception?
+               public void WriteStringForBoolean ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteStartElement ("foo");
+                       w.WriteAttributeString ("type", "boolean");
+                       w.WriteString ("xyz");
+                       w.WriteEndElement ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteStringForObject ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteString ("1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteArrayNonItem ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartElement ("foo");
+                       w.WriteAttributeString ("type", "array");
+                       w.WriteStartElement ("bar");
+               }
+
+               [Test]
+               public void WriteArray ()
+               {
+                       w.WriteStartElement ("root"); // name is ignored
+                       w.WriteAttributeString ("type", "array");
+                       w.WriteElementString ("item", "v1");
+                       w.WriteElementString ("item", "v2");
+                       w.Close ();
+                       Assert.AreEqual (@"[""v1"",""v2""]", ResultString, 
"#1");
+               }
+
+               [Test]
+               public void WriteArrayInObject ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteStartElement ("foo");
+                       w.WriteAttributeString ("type", "array");
+                       w.WriteElementString ("item", "v1");
+                       w.WriteElementString ("item", "v2");
+                       w.Close ();
+                       Assert.AreEqual (@"{""foo"":[""v1"",""v2""]}", 
ResultString, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void WriteStartElementNonEmptyNS ()
+               {
+                       // namespaces are not allowed
+                       w.WriteStartElement (String.Empty, "x", "urn:foo");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void WriteStartElementNonEmptyPrefix ()
+               {
+                       // prefixes are not allowed
+                       w.WriteStartElement ("p", "x", "urn:foo");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteStartElementMultiTopLevel ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteEndElement ();
+                       // hmm...
+                       Assert.AreEqual (WriteState.Content, w.WriteState, 
"#1");
+                       // writing of multiple root elements is not supported
+                       w.WriteStartElement ("root2");
+                       w.Close ();
+                       Assert.AreEqual (String.Empty, ResultString, "#2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void WriteStartAttributeNonEmptyNS ()
+               {
+                       // namespaces are not allowed
+                       w.WriteStartElement ("root");
+                       // well, empty prefix for a global attribute would be
+                       // replaced anyways ...
+                       w.WriteStartAttribute (String.Empty, "x", "urn:foo");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void WriteStartAttributeInXmlNamespace ()
+               {
+                       // even "xml" namespace is not allowed (anyways only 
"type" is allowed ...)
+                       w.WriteStartElement ("root");
+                       w.WriteStartAttribute ("xml", "lang", 
"http://www.w3.org/XML/1998/namespace";);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void LookupPrefixNull ()
+               {
+                       w.LookupPrefix (null);
+               }
+
+               [Test]
+               public void LookupPrefix ()
+               {
+                       // since namespaces are not allowed, it mostly makes no 
sense...
+                       Assert.AreEqual (String.Empty, w.LookupPrefix 
(String.Empty), "#1");
+                       Assert.IsNull (w.LookupPrefix ("urn:nonexistent"), 
"#2");
+                       Assert.AreEqual ("xml", w.LookupPrefix 
("http://www.w3.org/XML/1998/namespace";), "#3");
+                       Assert.AreEqual ("xmlns", w.LookupPrefix 
("http://www.w3.org/2000/xmlns/";), "#4");
+               }
+
+               [Test]
+               public void WriteStartDocument ()
+               {
+                       Assert.AreEqual (WriteState.Start, w.WriteState, "#1");
+                       w.WriteStartDocument ();
+                       Assert.AreEqual (WriteState.Start, w.WriteState, "#2");
+                       w.WriteStartDocument (true);
+                       Assert.AreEqual (WriteState.Start, w.WriteState, "#3");
+                       // So, it does nothing
+               }
+
+               [Test]
+               public void WriteEndDocument ()
+               {
+                       w.WriteEndDocument (); // so, it is completely wrong, 
but ignored.
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void WriteDocType ()
+               {
+                       w.WriteDocType (null, null, null, null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void WriteComment ()
+               {
+                       w.WriteComment ("test");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void WriteEntityRef ()
+               {
+                       w.WriteEntityRef ("ent");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void WriteProcessingInstruction ()
+               {
+                       // since this method accepts case-insensitive "XML",
+                       // it throws ArgumentException.
+                       w.WriteProcessingInstruction ("T", "D");
+               }
+
+               [Test]
+               public void WriteProcessingInstructionXML ()
+               {
+                       // You might not know, but in some cases, things like
+                       // XmlWriter.WriteNode() is implemented to invoke
+                       // this method for writing XML declaration. This
+                       // check is (seems) case-insensitive.
+                       w.WriteProcessingInstruction ("XML", "foobar");
+                       // In this case, the data is simply ignored (as
+                       // WriteStartDocument() is).
+               }
+
+               [Test]
+               public void WriteRaw ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteRaw ("sample");
+                       w.WriteRaw (new char [] {'0', '1', '2', '3'}, 1, 2);
+                       w.Close ();
+                       Assert.AreEqual ("\"sample12\"", ResultString);
+               }
+
+               [Test]
+               public void WriteCData ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteCData ("]]>"); // this behavior is incompatible 
with ordinal XmlWriters.
+                       w.Close ();
+                       Assert.AreEqual ("\"]]>\"", ResultString);
+               }
+
+               [Test]
+               public void WriteCharEntity ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteCharEntity ('>');
+                       w.Close ();
+                       Assert.AreEqual ("\">\"", ResultString);
+               }
+
+               [Test]
+               public void WriteWhitespace ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteWhitespace ("\t  \n\r");
+                       w.Close ();
+                       Assert.AreEqual (@"""\u0009  \u000a\u000d""", 
ResultString);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void WriteWhitespaceNonWhitespace ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteWhitespace ("TEST");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void WriteStringTopLevel ()
+               {
+                       w.WriteString ("test");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteStartAttributeTopLevel ()
+               {
+                       w.WriteStartAttribute ("test");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void WriteStartDocumentAtClosed ()
+               {
+                       w.Close ();
+                       w.WriteStartDocument ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void WriteStartElementAtClosed ()
+               {
+                       w.Close ();
+                       w.WriteStartElement ("foo");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void WriteProcessingInstructionAtClosed ()
+               {
+                       w.Close ();
+                       w.WriteProcessingInstruction ("xml", "version='1.0'");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteMixedContent ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteString ("TEST");
+                       w.WriteStartElement ("mixed"); // is not allowed.
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteStartElementInvalidTopLevelName ()
+               {
+                       w.WriteStartElement ("anyname");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void WriteStartElementNullName ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteStartElement (null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void WriteStartElementEmptyName ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteStartElement (String.Empty);
+                       // It is regarded as invalid name in JSON. However,
+                       // I don't think there is such specification in JSON.
+               }
+
+               [Test]
+               public void WriteStartElementWeirdName ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteAttributeString ("type", "object");
+                       w.WriteStartElement ("!!!");
+                       w.Close ();
+                       Assert.AreEqual (@"{""!!!"":""""}", ResultString);
+               }
+
+               [Test]
+               public void WriteRootAsObject ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartAttribute ("type");
+                       w.WriteString ("object");
+                       w.WriteEndAttribute ();
+                       w.Close ();
+                       Assert.AreEqual ("{}", ResultString);
+               }
+
+               [Test]
+               public void WriteRootAsArray ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartAttribute ("type");
+                       w.WriteString ("array");
+                       w.WriteEndAttribute ();
+                       w.Close ();
+                       Assert.AreEqual ("[]", ResultString);
+               }
+
+               [Test]
+               public void WriteRootAsLiteral ()
+               {
+                       w.WriteStartElement ("root");
+                       w.Close ();
+                       Assert.AreEqual ("\"\"", ResultString);
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteEndElementOnAttribute ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartAttribute ("type");
+                       w.WriteString ("array");
+                       w.WriteEndElement ();
+               }
+
+               [Test]
+               public void WriteAttributeAsSeparateStrings ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartAttribute ("type");
+                       w.WriteString ("arr");
+                       w.WriteString ("ay");
+                       w.WriteEndAttribute ();
+                       w.Close ();
+                       Assert.AreEqual ("[]", ResultString);
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteStartAttributeInAttributeMode ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartAttribute ("type");
+                       w.WriteStartAttribute ("type");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteStartAttributeInContentMode ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteString ("TEST");
+                       w.WriteStartAttribute ("type");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void WriteStartElementInAttributeMode ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartAttribute ("type");
+                       w.WriteStartElement ("child");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void CloseAtAtributeState ()
+               {
+                       w.WriteStartElement ("root");
+                       w.WriteStartAttribute ("type");
+                       w.WriteString ("array");
+                       // It calls WriteEndElement() without calling
+                       // WriteEndAttribute().
+                       w.Close ();
+               }
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.Xml/JsonWriterTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

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

Reply via email to