コード例 #1
0
ファイル: HttpServiceExtensions.cs プロジェクト: chubrik/Kit
        public static async Task <T> GetObjectAsync <T>(
            this HttpService http, Uri uri, CancellationToken cancellationToken,
            CacheMode?cache = null, string?cacheKey = null, bool?repeat = null, int?timeoutSeconds = null)
            where T : class, new()
        {
            using var responseStream = await http.GetStreamAsync(uri, cancellationToken,
                                                                 cache : cache, cacheKey : cacheKey, repeat : repeat, timeoutSeconds : timeoutSeconds);

            return(JsonHelper.Deserialize <T>(responseStream));
        }
コード例 #2
0
ファイル: HttpServiceExtensions.cs プロジェクト: chubrik/Kit
 public static Task <Stream> GetStreamAsync(
     this HttpService http, string url, CancellationToken cancellationToken,
     CacheMode?cache = null, string?cacheKey = null, bool?repeat = null, int?timeoutSeconds = null) =>
 http.GetStreamAsync(new Uri(url), cancellationToken,
                     cache: cache, cacheKey: cacheKey, repeat: repeat, timeoutSeconds: timeoutSeconds);
コード例 #3
0
ファイル: HttpServiceExtensions.cs プロジェクト: chubrik/Kit
 public static Stream GetStream(
     this HttpService http, Uri uri,
     CacheMode?cache = null, string?cacheKey = null, bool?repeat = null, int?timeoutSeconds = null) =>
 Task.Run(() => http.GetStreamAsync(uri, Kit.CancellationToken,
                                    cache: cache, cacheKey: cacheKey, repeat: repeat, timeoutSeconds: timeoutSeconds)).Result;