Created
March 17, 2016 10:07
-
-
Save chrisumbel/bec83a46ff58e95a7cbe to your computer and use it in GitHub Desktop.
DOTNET VCAP Services Parser
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
| // using Newtonsoft.Json.Linq; | |
| private String VCAPServices() { | |
| if (Environment.GetEnvironmentVariable("VCAP_SERVICES") == null) | |
| { | |
| return @" { | |
| ""user-provided"": [ | |
| { | |
| ""credentials"": { | |
| ""uri"": ""http://localhost:13471"" | |
| }, | |
| ""label"": ""user-provided"", | |
| ""name"": ""umbel-beverage"", | |
| ""syslog_drain_url"": """", | |
| ""tags"": [] | |
| } | |
| ] | |
| } | |
| "; | |
| } | |
| else { | |
| return Environment.GetEnvironmentVariable("VCAP_SERVICES"); | |
| } | |
| } | |
| private string ServivceURL() { | |
| JObject vcapServices = JObject.Parse(VCAPServices()); | |
| return vcapServices["user-provided"].First( | |
| o => o["name"].ToString() == "umbel-beverage")["credentials"]["uri"].ToString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment