diff options
author | csharptest <roger@csharptest.net> | 2011-06-11 12:22:17 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-06-11 12:22:17 -0500 |
commit | 3b70dd78ec6b3b348b51766ea728d8226c908fd6 (patch) | |
tree | 37660dd74701f61dbbff7fe23fd2b8b3679c654d /src/ProtocolBuffers/Serialization/DictionaryWriter.cs | |
parent | 57fa7fddd7255acf5169462ae08b71b4c73b6b18 (diff) | |
download | protobuf-3b70dd78ec6b3b348b51766ea728d8226c908fd6.tar.gz protobuf-3b70dd78ec6b3b348b51766ea728d8226c908fd6.tar.bz2 protobuf-3b70dd78ec6b3b348b51766ea728d8226c908fd6.zip |
Added recursion limits to AbstractReader.cs
Diffstat (limited to 'src/ProtocolBuffers/Serialization/DictionaryWriter.cs')
-rw-r--r-- | src/ProtocolBuffers/Serialization/DictionaryWriter.cs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ProtocolBuffers/Serialization/DictionaryWriter.cs b/src/ProtocolBuffers/Serialization/DictionaryWriter.cs index 596a9262..ccfa31f0 100644 --- a/src/ProtocolBuffers/Serialization/DictionaryWriter.cs +++ b/src/ProtocolBuffers/Serialization/DictionaryWriter.cs @@ -15,7 +15,7 @@ namespace Google.ProtocolBuffers.Serialization /// Constructs a writer using a new dictionary
/// </summary>
public DictionaryWriter()
- : this(new Dictionary<string,object>())
+ : this(new Dictionary<string,object>(StringComparer.Ordinal))
{ }
/// <summary>
@@ -28,6 +28,14 @@ namespace Google.ProtocolBuffers.Serialization }
/// <summary>
+ /// Creates the dictionary instance for a child message.
+ /// </summary>
+ protected virtual DictionaryWriter Create()
+ {
+ return new DictionaryWriter();
+ }
+
+ /// <summary>
/// Accesses the dictionary that is backing this writer
/// </summary>
public IDictionary<string, object> ToDictionary() { return _output; }
@@ -119,7 +127,7 @@ namespace Google.ProtocolBuffers.Serialization /// </summary>
protected override void WriteMessageOrGroup(string field, IMessageLite message)
{
- DictionaryWriter writer = new DictionaryWriter();
+ DictionaryWriter writer = Create();
writer.WriteMessage(message);
_output[field] = writer.ToDictionary();
@@ -146,7 +154,7 @@ namespace Google.ProtocolBuffers.Serialization case FieldType.Group:
case FieldType.Message:
{
- DictionaryWriter writer = new DictionaryWriter();
+ DictionaryWriter writer = Create();
writer.WriteMessage((IMessageLite)o);
objects.Add(writer.ToDictionary());
}
|