private static async Task SetLocalCacheAsync(string key, string content) { if (Configuration.Instance.UseLocalCache) { string fileName = LocalCacheUtils.GetFullPath(key); using (var file = File.CreateText(fileName)) { await file.WriteLineAsync(content); } } }
private static async Task SetLocalCacheAsync(string key, GetSireneAccessTokenResponse token) { if (Configuration.Instance.UseLocalCache) { string fileName = LocalCacheUtils.GetFullPath("sirene_token.json"); using (var file = File.CreateText(fileName)) { await file.WriteLineAsync(JsonConvert.SerializeObject(token)); } } }
private static async Task <string> GetLocalCacheAsync(string key) { if (key != null) { string fileName = LocalCacheUtils.GetFullPath(key); if (Configuration.Instance.UseLocalCache && File.Exists(fileName)) { using (var file = File.OpenText(fileName)) { return(await file.ReadToEndAsync()); } } } return(null); }
private static async Task <GetSireneAccessTokenResponse> GetLocalCacheAsync(string key) { if (key != null) { string fileName = LocalCacheUtils.GetFullPath(key); if (Configuration.Instance.UseLocalCache && File.Exists(fileName)) { using (var file = File.OpenText(fileName)) { string json = await file.ReadToEndAsync(); return(JsonConvert.DeserializeObject <GetSireneAccessTokenResponse>(json, JsonUtils.SerializerSettings)); } } } return(null); }