wasSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 23  →  ?path2? @ 24
/KeyValue.cs
@@ -102,9 +102,22 @@
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/// <summary>
/// Serialises a dictionary to key-value data.
/// </summary>
/// <returns>a key-value data encoded string</returns>
public static string Encode(IEnumerable<KeyValuePair<string, string>> data)
{
return string.Join("&", data.AsParallel().Select(o => string.Join("=", o.Key, o.Value)));
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/// <summary>
/// Escapes a dictionary's keys and values for sending as POST data.
/// </summary>
public static Dictionary<string, string> Escape(Dictionary<string, string> data, Func<string, string> func)
public static IEnumerable<KeyValuePair<string, string>> Escape(IEnumerable<KeyValuePair<string, string>> data,
Func<string, string> func)
{
return data.AsParallel().ToDictionary(o => func(o.Key), p => func(p.Value));
}