From e669617eed2dd4e5baefc43dbc8ee7a9ed8e867c Mon Sep 17 00:00:00 2001 From: Neil Campbell Date: Thu, 4 Jun 2015 11:20:45 +1000 Subject: [PATCH] Changing the cast to be safer as IDictionary does not implement IDictionary --- .../PreserveCasingDictionaryConverter.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/PactNet/Configuration/Json/Converters/PreserveCasingDictionaryConverter.cs b/PactNet/Configuration/Json/Converters/PreserveCasingDictionaryConverter.cs index 15ee8ef1..66cf0901 100644 --- a/PactNet/Configuration/Json/Converters/PreserveCasingDictionaryConverter.cs +++ b/PactNet/Configuration/Json/Converters/PreserveCasingDictionaryConverter.cs @@ -1,6 +1,5 @@ using System; -using System.Collections; -using System.Globalization; +using System.Collections.Generic; using Newtonsoft.Json; namespace PactNet.Configuration.Json.Converters @@ -15,15 +14,14 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s } else { - var dictionary = (IDictionary) value; + var dictionary = (IDictionary) value; writer.WriteStartObject(); - foreach (DictionaryEntry entry in dictionary) + foreach (var item in dictionary) { - var key = Convert.ToString(entry.Key, CultureInfo.InvariantCulture); - writer.WritePropertyName(key); - serializer.Serialize(writer, entry.Value); + writer.WritePropertyName(item.Key); + serializer.Serialize(writer, item.Value); } writer.WriteEndObject(); @@ -42,7 +40,7 @@ public override bool CanRead public override bool CanConvert(Type objectType) { - return typeof(IDictionary).IsAssignableFrom(objectType); + return typeof(IDictionary).IsAssignableFrom(objectType); } } } \ No newline at end of file