Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed compiler updates, polished UI
- Loading branch information
Showing
9 changed files
with
217 additions
and
125 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace coop_builder | ||
{ | ||
public static class RestUtil | ||
{ | ||
public static async Task<string> GetAsync(string url) | ||
{ | ||
using (var client = new HttpClient()) | ||
{ | ||
client.DefaultRequestHeaders.Accept.Clear(); | ||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json")); | ||
client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (compatible; AcmeInc/1.0)"); | ||
|
||
// HTTP GET | ||
HttpResponseMessage response = await client.GetAsync(url); | ||
if (response.IsSuccessStatusCode) | ||
{ | ||
string result = await response.Content.ReadAsStringAsync(); | ||
return result; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static string SloppyExtract(string json, string field) | ||
{ | ||
json = json.Replace(" ", ""); | ||
|
||
string fieldJson = "\"" + field + "\":"; | ||
if (!json.Contains(fieldJson)) { return null; } | ||
|
||
string after = json.Split(new string[] { fieldJson }, 2, StringSplitOptions.RemoveEmptyEntries)[1]; | ||
string[] valueSplit = after.Split('"'); | ||
if (valueSplit.Count() < 2) { return null; } | ||
|
||
return valueSplit[1]; | ||
} | ||
|
||
public static async Task<string> GetSloppyAsync(string url, string parameter) | ||
{ | ||
string jsonString = await GetAsync(url); | ||
if (jsonString == null) { return null; } | ||
|
||
return SloppyExtract(jsonString, parameter); | ||
} | ||
} | ||
} |
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
Binary file not shown.
This file was deleted.
Oops, something went wrong.