diff --git a/X10D/src/DictionaryExtensions.cs b/X10D/src/DictionaryExtensions.cs index 359a81b..3e87521 100644 --- a/X10D/src/DictionaryExtensions.cs +++ b/X10D/src/DictionaryExtensions.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Web; @@ -19,6 +20,11 @@ namespace X10D /// Returns a representing the dictionary as a key=value; set. public static string ToConnectionString(this IReadOnlyDictionary dictionary) { + if (dictionary is null) + { + throw new ArgumentNullException(nameof(dictionary)); + } + static string SanitizeValue(string? value) { if (value is null) @@ -37,8 +43,14 @@ namespace X10D return value; } - var strings = dictionary.Select(o => $"{o.Key}={SanitizeValue(o.Value?.ToString())}"); - return string.Join(";", strings); + var list = new List(); + + foreach (var pair in dictionary) + { + list.Add($"{pair.Key}={SanitizeValue(pair.Value?.ToString())}"); + } + + return string.Join(";", list); } ///