BibleBrainSharp by markivan.basto

<PackageReference Include="BibleBrainSharp" Version="0.3.0-beta" />

 ApiExtensions

public static class ApiExtensions
using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Net; using System.Net.Http; using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace BibleBrainSharp { public static class ApiExtensions { [AsyncStateMachine(typeof(<ExecuteAsync>d__0<>))] public static Task<T> ExecuteAsync<T>(this HttpClient client, HttpRequest request) { <ExecuteAsync>d__0<T> stateMachine = default(<ExecuteAsync>d__0<T>); stateMachine.<>t__builder = AsyncTaskMethodBuilder<T>.Create(); stateMachine.client = client; stateMachine.request = request; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } public static void AddRequiredParameter(this NameValueCollection query, string key, string value) { if (!string.IsNullOrEmpty(value)) { query.Add(key, value); return; } throw new ArgumentNullException("value"); } public static void AddRequiredParameter<T>(this NameValueCollection query, string key, T value) where T : struct { query.Add(key, value.ToString()); } public static void AddOptionalParameter(this NameValueCollection query, string key, string value) { if (!string.IsNullOrEmpty(value)) query.Add(key, value); } public static void AddOptionalParameter<T>(this NameValueCollection query, string key, T? value) where T : struct { if (value.HasValue) { T value2 = value.Value; if (((object)value2) is bool) query.Add(key, (value2 as bool) ? "true" : "false"); else { value2 = value.Value; query.Add(key, value2.ToString()); } } } public static string ToQueryString(this NameValueCollection query) { IEnumerable<string> values = from key in query.AllKeys from value in query.GetValues(key) select $"{WebUtility.UrlEncode(key)}""{WebUtility.UrlEncode(value)}"; return string.Join("&", values); } } }