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,23 @@
using System.Reflection;
namespace RobotNet.WebApp.Helpers;
public static class DefaultPersistentStorageConfigurationExtensions
{
/// <summary>
/// Sửa lỗi Exception "System.Diagnostics.Process is not supported on this platform."
/// trong static constructor của Microsoft.CodeAnalysis.Host.DefaultPersistentStorageConfiguration
/// khi gọi CompletionService.GetCompletionsAsync
/// </summary>
public static void FixStaticConstructorException()
{
try
{
_ = typeof(Microsoft.CodeAnalysis.Host.HostServices).Assembly.CreateInstance("Microsoft.CodeAnalysis.Host.DefaultPersistentStorageConfiguration");
}
catch (TargetInvocationException)
{
GC.Collect();
}
}
}

View File

@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using System.Net.Http.Headers;
namespace RobotNet.WebApp.Helpers;
public static class ServiceCollectionExtensions
{
public static IHttpClientBuilder AddAuthorizationHttpClient(this IServiceCollection services, string name, string baseAddress)
{
return services.AddHttpClient(name, client =>
{
client.BaseAddress = new Uri(baseAddress);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
})
.AddHttpMessageHandler(sp =>
{
var tokenProvider = sp.GetRequiredService<IAccessTokenProvider>();
var navigation = sp.GetRequiredService<NavigationManager>();
var messageHandle = new AuthorizationMessageHandler(tokenProvider, navigation);
messageHandle.ConfigureHandler([baseAddress]);
return messageHandle;
})
.RemoveAllLoggers();
}
}