예제 #1
0
 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);
         }
     }
 }
예제 #2
0
 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));
         }
     }
 }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }