Created
July 21, 2017 15:39
-
-
Save nozzlegear/14eb07ce83a8bb8799ffcac24767e2b3 to your computer and use it in GitHub Desktop.
Convert MVC5's QueryString to a List<KeyValuePair<string, StringValues>> needed by ShopifySharp's auth service.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyNamespace | |
{ | |
public static class Extensions | |
{ | |
public List<KeyValuePair<string, StringValues>> ToKvps(this System.Collections.Specialized.NameValueCollection qs) | |
{ | |
Dictionary<string, string> parameters = qs.Keys.Cast<string>().ToDictionary(key => key, value => qs[value]); | |
var kvps = new List<KeyValuePair<string, StringValues>>(); | |
parameters.ToList().ForEach(x => | |
{ | |
kvps.Add(new KeyValuePair<string, StringValues>(x.Key, new StringValues(x.Value))); | |
}); | |
return kvps; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment