Created
February 2, 2015 16:09
-
-
Save JonCanning/a7815917af9ab814da24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| let asQueryString o = | |
| o.GetType().GetProperties() | |
| |> Array.map (fun p -> (p.Name, p.GetValue(o) |> string)) | |
| |> Array.map (fun (name, value) -> | |
| let m = Regex.Match(value, "Some\((?<value>.*?)\)") | |
| (name, if m.Groups.Count = 2 then m.Groups.["value"].Value else value)) | |
| |> Array.map (fun (name, value) -> sprintf "%s=%s" name value) | |
| |> String.concat "&" | |
| |> sprintf "?%s" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment