public static async Task <T> CacheOf <T>(int id) where T : ApiObject { var type = typeof(T); if (!ShouldCacheData) { return(JsonConvert.DeserializeObject <T>(await Client.GetStringAsync(BASE_URL + UrlOfType[type] + SLASH + id))); } if (!Cache.ContainsKey(type)) { Cache.Add(type, new Dictionary <int, ApiObject>()); } var dictionary = Cache[type]; if (!dictionary.TryGetValue(id, out var apiObject)) { apiObject = JsonConvert.DeserializeObject <T>(await Client.GetStringAsync(BASE_URL + UrlOfType[type] + SLASH + id)); dictionary.Add(id, apiObject); } return((T)apiObject); }
static async Task <JsonData> GetJsonAsync(Uri url) => JsonMapper.ToObject(await client.GetStringAsync(url.AbsoluteUri));
static async Task <JsonData> GetJsonAsync(string obj) => JsonMapper.ToObject(await client.GetStringAsync(BASE_URL + obj));