diff options
author | csharptest <roger@csharptest.net> | 2011-09-09 12:18:16 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-09-09 12:18:16 -0500 |
commit | 60fd773d300cd0390ba08812590690ab2d28c837 (patch) | |
tree | 292994e6c5602566ed50d9911522f2e5e80515b1 /src/ProtocolBuffers.Serialization/JsonFormatWriter.cs | |
parent | 819b7154d162f3ef4f187f19b020f999c02fcf03 (diff) | |
download | protobuf-60fd773d300cd0390ba08812590690ab2d28c837.tar.gz protobuf-60fd773d300cd0390ba08812590690ab2d28c837.tar.bz2 protobuf-60fd773d300cd0390ba08812590690ab2d28c837.zip |
Completed work and testing for manually reading/writing start/end message
Diffstat (limited to 'src/ProtocolBuffers.Serialization/JsonFormatWriter.cs')
-rw-r--r-- | src/ProtocolBuffers.Serialization/JsonFormatWriter.cs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs index 5f396ae5..f387f39d 100644 --- a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs +++ b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs @@ -1,4 +1,4 @@ -using System;
+using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
@@ -101,7 +101,7 @@ namespace Google.ProtocolBuffers.Serialization private class JsonStreamWriter : JsonFormatWriter
{
#if SILVERLIGHT2 || COMPACT_FRAMEWORK_35
- static readonly Encoding Encoding = Encoding.UTF8;
+ static readonly Encoding Encoding = new UTF8Encoding(false);
#else
private static readonly Encoding Encoding = Encoding.ASCII;
#endif
@@ -244,9 +244,10 @@ namespace Google.ProtocolBuffers.Serialization /// </summary>
protected override void Dispose(bool disposing)
{
- if (disposing && _counter.Count == 1)
+ if (disposing)
{
- EndMessage();
+ while(_counter.Count > 1)
+ WriteMessageEnd();
}
base.Dispose(disposing);
@@ -458,17 +459,17 @@ namespace Google.ProtocolBuffers.Serialization /// </summary>
public override void WriteMessage(IMessageLite message)
{
- StartMessage();
+ WriteMessageStart();
message.WriteTo(this);
- EndMessage();
+ WriteMessageEnd();
}
/// <summary>
/// Used to write the root-message preamble, in json this is the left-curly brace '{'.
/// After this call you can call IMessageLite.MergeTo(...) and complete the message with
- /// a call to EndMessage().
+ /// a call to WriteMessageEnd().
/// </summary>
- public override void StartMessage()
+ public override void WriteMessageStart()
{
if (_isArray)
{
@@ -479,9 +480,9 @@ namespace Google.ProtocolBuffers.Serialization }
/// <summary>
- /// Used to complete a root-message previously started with a call to StartMessage()
+ /// Used to complete a root-message previously started with a call to WriteMessageStart()
/// </summary>
- public override void EndMessage()
+ public override void WriteMessageEnd()
{
_counter.RemoveAt(_counter.Count - 1);
WriteLine("}");
|