ant-design-blazor/components/core/Extensions/HttpClientExtensions.cs
Henry.zhang 7b31935f74 docs: add icon list (#478)
* feat: add icon list for demo page of icon

* feat: add copy function for icon list

* feat: get existed icon

* feat: remove some blanks in list.razor

* feat: remove some blanks

* fix: default value is outline for icon list

* fix: click to copy for icon list

* feat: add async to load icon list

* feat: update iconlistService

* chore: update icons

* fix: icon load async

* feat: add application icons in IconlistServices

* fix: remove the exist icon from existed catogory if duplicated

* fix: add @key for list items

* fix: revert the change

Co-authored-by: ElderJames <shunjiey@hotmail.com>
2020-08-14 07:13:28 +08:00

28 lines
808 B
C#

using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace AntDesign.core.Extensions
{
public static class HttpClientExtensions
{
public static async Task<TValue> GetFromJsonAsync<TValue>(this HttpClient client, string requestUri, CancellationToken cancellationToken = default)
{
if (client == null)
{
throw new ArgumentNullException(nameof(client));
}
var res = await client.GetAsync(requestUri);
if (res.IsSuccessStatusCode)
{
var json = await res.Content.ReadAsStreamAsync();
return await System.Text.Json.JsonSerializer.DeserializeAsync<TValue>(json);
}
return default;
}
}
}