aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcsharptest <roger@csharptest.net>2011-10-01 08:54:22 -0500
committerrogerk <devnull@localhost>2011-10-01 08:54:22 -0500
commitb1f746fd718ae86e36f9e3df8b6194b6fcdc8255 (patch)
tree421323bdfe0a4307c8a74da011a7218e50a3671c /src
parent2bb466e497c0a49378072ca221e5af38bd6309a1 (diff)
parentc96ed3bb5daa4ea1f72fd36380ea07969e1c461c (diff)
downloadprotobuf-b1f746fd718ae86e36f9e3df8b6194b6fcdc8255.tar.gz
protobuf-b1f746fd718ae86e36f9e3df8b6194b6fcdc8255.tar.bz2
protobuf-b1f746fd718ae86e36f9e3df8b6194b6fcdc8255.zip
merged issue-33 correction
Diffstat (limited to 'src')
-rw-r--r--src/ProtocolBuffers/EnumLite.cs4
-rw-r--r--src/ProtocolBuffers/FieldSet.cs20
-rw-r--r--src/ProtocolBuffers/ProtocolBuffersLite.csproj1
3 files changed, 5 insertions, 20 deletions
diff --git a/src/ProtocolBuffers/EnumLite.cs b/src/ProtocolBuffers/EnumLite.cs
index 527a29d8..42344835 100644
--- a/src/ProtocolBuffers/EnumLite.cs
+++ b/src/ProtocolBuffers/EnumLite.cs
@@ -93,11 +93,11 @@ namespace Google.ProtocolBuffers
}
}
- private readonly Dictionary<int, IEnumLite> items;
+ private readonly SortedList<int, IEnumLite> items;
public EnumLiteMap()
{
- items = new Dictionary<int, IEnumLite>();
+ items = new SortedList<int, IEnumLite>();
#if SILVERLIGHT2
// Silverlight doesn't support Enum.GetValues
// TODO(jonskeet): Validate that this reflection is permitted, e.g. in Windows Phone 7
diff --git a/src/ProtocolBuffers/FieldSet.cs b/src/ProtocolBuffers/FieldSet.cs
index 27699771..f3c08cf5 100644
--- a/src/ProtocolBuffers/FieldSet.cs
+++ b/src/ProtocolBuffers/FieldSet.cs
@@ -87,12 +87,8 @@ namespace Google.ProtocolBuffers
public static FieldSet CreateInstance()
{
-#if SILVERLIGHT2
- return new FieldSet(new Dictionary<IFieldDescriptorLite, object>());
-#else
// Use SortedList to keep fields in the canonical order
return new FieldSet(new SortedList<IFieldDescriptorLite, object>());
-#endif
}
/// <summary>
@@ -313,16 +309,7 @@ namespace Google.ProtocolBuffers
/// </summary>
internal IEnumerator<KeyValuePair<IFieldDescriptorLite, object>> GetEnumerator()
{
-#if SILVERLIGHT2
- List<KeyValuePair<IFieldDescriptorLite, object>> result = new List<KeyValuePair<IFieldDescriptorLite, object>>(fields);
- result.Sort(
- delegate(KeyValuePair<IFieldDescriptorLite, object> a, KeyValuePair<IFieldDescriptorLite, object> b)
- { return a.Key.CompareTo(b.Key); }
- );
- return result.GetEnumerator();
-#else
return fields.GetEnumerator();
-#endif
}
/// <summary>
@@ -474,12 +461,9 @@ namespace Google.ProtocolBuffers
/// </summary>
public void WriteTo(ICodedOutputStream output)
{
- using (IEnumerator<KeyValuePair<IFieldDescriptorLite, object>> e = GetEnumerator())
+ foreach (KeyValuePair<IFieldDescriptorLite, object> entry in fields)
{
- while (e.MoveNext())
- {
- WriteField(e.Current.Key, e.Current.Value, output);
- }
+ WriteField(entry.Key, entry.Value, output);
}
}
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.csproj b/src/ProtocolBuffers/ProtocolBuffersLite.csproj
index 66edab75..bc58bf11 100644
--- a/src/ProtocolBuffers/ProtocolBuffersLite.csproj
+++ b/src/ProtocolBuffers/ProtocolBuffersLite.csproj
@@ -110,6 +110,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="InvalidProtocolBufferException.cs" />
+ <Compile Include="SortedList.cs" />
<Compile Include="ThrowHelper.cs" />
<Compile Include="UninitializedMessageException.cs" />
<Compile Include="WireFormat.cs" />