wasSharp – Diff between revs 23 and 24
?pathlinks?
Rev 23 | Rev 24 | |||
---|---|---|---|---|
Line 100... | Line 100... | |||
100 | |
100 | |
|
101 | /////////////////////////////////////////////////////////////////////////// |
101 | /////////////////////////////////////////////////////////////////////////// |
|
102 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
102 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
103 | /////////////////////////////////////////////////////////////////////////// |
103 | /////////////////////////////////////////////////////////////////////////// |
|
- | 104 | /// <summary> |
||
- | 105 | /// Serialises a dictionary to key-value data. |
||
- | 106 | /// </summary> |
||
- | 107 | /// <returns>a key-value data encoded string</returns> |
||
- | 108 | public static string Encode(IEnumerable<KeyValuePair<string, string>> data) |
||
- | 109 | { |
||
- | 110 | return string.Join("&", data.AsParallel().Select(o => string.Join("=", o.Key, o.Value))); |
||
- | 111 | } |
||
- | 112 | |
||
- | 113 | /////////////////////////////////////////////////////////////////////////// |
||
- | 114 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
||
- | 115 | /////////////////////////////////////////////////////////////////////////// |
||
104 | /// <summary> |
116 | /// <summary> |
|
105 | /// Escapes a dictionary's keys and values for sending as POST data. |
117 | /// Escapes a dictionary's keys and values for sending as POST data. |
|
106 | /// </summary> |
118 | /// </summary> |
|
- | 119 | public static IEnumerable<KeyValuePair<string, string>> Escape(IEnumerable<KeyValuePair<string, string>> data, |
||
107 | public static Dictionary<string, string> Escape(Dictionary<string, string> data, Func<string, string> func) |
120 | Func<string, string> func) |
|
108 | { |
121 | { |
|
109 | return data.AsParallel().ToDictionary(o => func(o.Key), p => func(p.Value)); |
122 | return data.AsParallel().ToDictionary(o => func(o.Key), p => func(p.Value)); |
|
110 | } |
123 | } |
|
111 | } |
124 | } |
|
112 | } |
125 | } |