first commit -push

This commit is contained in:
dungtt
2025-10-15 15:15:53 +07:00
parent 674ae395be
commit a9577c5756
885 changed files with 74595 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
using System.Net.Http.Json;
namespace RobotNet.Clients;
public static class HttpClientExtensions
{
public static async Task<TValue?> PostFromJsonAsync<TValue>(this HttpClient client, string requestUri, object value)
{
var response = await client.PostAsJsonAsync(requestUri, value);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<TValue>();
}
return default;
}
public static async Task<TValue?> PutFromJsonAsync<TValue>(this HttpClient client, string requestUri, object value)
{
var response = await client.PutAsJsonAsync(requestUri, value);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<TValue>();
}
return default;
}
public static async Task<TValue?> PatchFromJsonAsync<TValue>(this HttpClient client, string requestUri, object value)
{
var response = await client.PatchAsJsonAsync(requestUri, value);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<TValue>();
}
return default;
}
}