public static async Task <T> CacheOfByUrl <T>(Uri url) where T : ApiObject { if (!ShouldCacheData) { return(JsonConvert.DeserializeObject <T>(await Client.GetStringAsync(url.AbsoluteUri))); } var type = typeof(T); if (!CacheUrl.ContainsKey(type)) { CacheUrl.Add(type, new Dictionary <Uri, ApiObject>()); } var dictionary = CacheUrl[type]; if (!dictionary.TryGetValue(url, out var apiObject)) { apiObject = JsonConvert.DeserializeObject <T>(await Client.GetStringAsync(url.AbsoluteUri)); dictionary.Add(url, apiObject); } return((T)apiObject); }
public static void ClearAll() { Cache.Clear(); CacheString.Clear(); CacheUrl.Clear(); }