using DysonNetwork.Shared.Proto; using Grpc.Net.ClientFactory; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace DysonNetwork.Shared.Registry; public static class ServiceInjectionHelper { public static IServiceCollection AddRingService(this IServiceCollection services) { services .AddGrpcClient(o => o.Address = new Uri("https://ring")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); return services; } public static IServiceCollection AddAuthService(this IServiceCollection services) { services .AddGrpcClient(o => o.Address = new Uri("https://pass")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services .AddGrpcClient(o => o.Address = new Uri("https://pass")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); return services; } public static IServiceCollection AddAccountService(this IServiceCollection services) { services .AddGrpcClient(o => o.Address = new Uri("https://pass")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services.AddSingleton(); services .AddGrpcClient(o => o.Address = new Uri("https://pass") ) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services.AddGrpcClient(o => o.Address = new Uri("https://pass")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services.AddGrpcClient(o => o.Address = new Uri("https://pass")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services.AddGrpcClient(o => o.Address = new Uri("https://pass")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services .AddGrpcClient(o => o.Address = new Uri("https://pass")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services.AddSingleton(); services .AddGrpcClient(o => o.Address = new Uri("https://pass")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services .AddGrpcClient(o => o.Address = new Uri("https://pass")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); return services; } public static IServiceCollection AddDriveService(this IServiceCollection services) { services.AddGrpcClient(o => o.Address = new Uri("https://drive")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services.AddGrpcClient(o => o.Address = new Uri("https://drive")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); return services; } public static IServiceCollection AddSphereService(this IServiceCollection services) { services .AddGrpcClient(o => o.Address = new Uri("https://sphere")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services .AddGrpcClient(o => o.Address = new Uri("https://sphere")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); services.AddSingleton(); return services; } public static IServiceCollection AddDevelopService(this IServiceCollection services) { services.AddGrpcClient(o => o.Address = new Uri("https://develop")) .ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler() { ServerCertificateCustomValidationCallback = (_, _, _, _) => true } ); return services; } }