Add project files.

This commit is contained in:
2026-03-08 20:45:01 +01:00
commit 053a4052dd
45 changed files with 2578 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
using System.Text.Json;
namespace LeagueAPI.Utils;
public class LcuHttpClient : HttpClient
{
private static readonly Lazy<LcuHttpClient> LazyInstance = new(() => new LcuHttpClient(new LcuHttpClientHandler()));
internal static LcuHttpClient Instance => LazyInstance.Value;
private LcuHttpClientHandler Handler { get; }
public ProcessInfo? ProcessInfo
{
get
{
return Handler.ProcessInfo;
}
internal set
{
Handler.ProcessInfo = value;
}
}
public RiotAuthentication? RiotAuthentication => Handler.RiotAuthentication;
internal LcuHttpClient(LcuHttpClientHandler lcuHttpClientHandler)
: base(lcuHttpClientHandler)
{
Handler = lcuHttpClientHandler;
base.BaseAddress = new Uri("https://127.0.0.1");
}
public async Task<T?> GetContentAsync<T>(string requestUri) where T : class
{
HttpResponseMessage response = await GetAsync(requestUri);
if (!response.IsSuccessStatusCode)
{
return null;
}
string content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<T>(content);
}
}