private Task <object> Fetch(string api, Method method, ContentType contentType, CancellationToken cancellationToken) { switch (method) { case Method.Post: var components = api.Split('?', 2, StringSplitOptions.RemoveEmptyEntries); var domain = components.First(); switch (contentType) { case ContentType.Json: default: var d1 = components.Length > 1 ? QueryStringHelper.ToObject <object>(components.Last()) : null; return(_httpService.PostJson <object>(new Uri(domain !), d1?.ToString(), cancellationToken !)); case ContentType.Form: var d2 = components.Length > 1 ? QueryStringHelper.ToDictionary(components.Last()) : new Dictionary <string, string>(); return(_httpService.PostUrlEncoded <object>(new Uri(domain !), d2 !, cancellationToken !)); case ContentType.Multi: // TODO this will crash var d3 = components.Length > 1 ? components.Last().AsDictionary() : new Dictionary <string, object?>(); return(_httpService.PostMultipart <object>(new Uri(domain !), d3 !, cancellationToken !)); } case Method.Get: default: return(_httpService.Get <object>(new Uri(api !), cancellationToken !)); } }