1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 23:45:42 +00:00

🐎 De-Linqify ToConnectionString

Item for #12
This commit is contained in:
Oliver Booth 2021-01-17 00:52:01 +00:00
parent 3ad20fdb40
commit db5512db59

View File

@ -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>Returns a <see cref="string" /> representing the dictionary as a key=value; set.</returns>
public static string ToConnectionString<T1, T2>(this IReadOnlyDictionary<T1, T2> 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<string>();
foreach (var pair in dictionary)
{
list.Add($"{pair.Key}={SanitizeValue(pair.Value?.ToString())}");
}
return string.Join(";", list);
}
/// <summary>