Commit b1f746fd authored by csharptest's avatar csharptest Committed by rogerk

merged issue-33 correction

parents 2bb466e4 c96ed3bb
...@@ -93,11 +93,11 @@ namespace Google.ProtocolBuffers ...@@ -93,11 +93,11 @@ namespace Google.ProtocolBuffers
} }
} }
private readonly Dictionary<int, IEnumLite> items; private readonly SortedList<int, IEnumLite> items;
public EnumLiteMap() public EnumLiteMap()
{ {
items = new Dictionary<int, IEnumLite>(); items = new SortedList<int, IEnumLite>();
#if SILVERLIGHT2 #if SILVERLIGHT2
// Silverlight doesn't support Enum.GetValues // Silverlight doesn't support Enum.GetValues
// TODO(jonskeet): Validate that this reflection is permitted, e.g. in Windows Phone 7 // TODO(jonskeet): Validate that this reflection is permitted, e.g. in Windows Phone 7
......
...@@ -87,12 +87,8 @@ namespace Google.ProtocolBuffers ...@@ -87,12 +87,8 @@ namespace Google.ProtocolBuffers
public static FieldSet CreateInstance() public static FieldSet CreateInstance()
{ {
#if SILVERLIGHT2
return new FieldSet(new Dictionary<IFieldDescriptorLite, object>());
#else
// Use SortedList to keep fields in the canonical order // Use SortedList to keep fields in the canonical order
return new FieldSet(new SortedList<IFieldDescriptorLite, object>()); return new FieldSet(new SortedList<IFieldDescriptorLite, object>());
#endif
} }
/// <summary> /// <summary>
...@@ -313,16 +309,7 @@ namespace Google.ProtocolBuffers ...@@ -313,16 +309,7 @@ namespace Google.ProtocolBuffers
/// </summary> /// </summary>
internal IEnumerator<KeyValuePair<IFieldDescriptorLite, object>> GetEnumerator() 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(); return fields.GetEnumerator();
#endif
} }
/// <summary> /// <summary>
...@@ -474,12 +461,9 @@ namespace Google.ProtocolBuffers ...@@ -474,12 +461,9 @@ namespace Google.ProtocolBuffers
/// </summary> /// </summary>
public void WriteTo(ICodedOutputStream output) public void WriteTo(ICodedOutputStream output)
{ {
using (IEnumerator<KeyValuePair<IFieldDescriptorLite, object>> e = GetEnumerator()) foreach (KeyValuePair<IFieldDescriptorLite, object> entry in fields)
{ {
while (e.MoveNext()) WriteField(entry.Key, entry.Value, output);
{
WriteField(e.Current.Key, e.Current.Value, output);
}
} }
} }
......
...@@ -110,6 +110,7 @@ ...@@ -110,6 +110,7 @@
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="InvalidProtocolBufferException.cs" /> <Compile Include="InvalidProtocolBufferException.cs" />
<Compile Include="SortedList.cs" />
<Compile Include="ThrowHelper.cs" /> <Compile Include="ThrowHelper.cs" />
<Compile Include="UninitializedMessageException.cs" /> <Compile Include="UninitializedMessageException.cs" />
<Compile Include="WireFormat.cs" /> <Compile Include="WireFormat.cs" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment