feat(Client.DIExtensions): Methode zur Behandlung von Dependency Injection erstellt
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
public class ClientParams
|
public class ClientParams
|
||||||
{
|
{
|
||||||
public required string Url { get; init; }
|
#pragma warning disable CS8618 // throw exception in DI extension if it not set
|
||||||
|
public string Url { get; set; }
|
||||||
|
#pragma warning restore CS8618
|
||||||
|
|
||||||
public readonly ClientEvents Events = new();
|
public readonly ClientEvents Events = new();
|
||||||
}
|
}
|
||||||
19
DigitalData.Auth.Client/DIExtensions.cs
Normal file
19
DigitalData.Auth.Client/DIExtensions.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using DigitalData.Auth.Abstractions;
|
||||||
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
|
||||||
|
namespace DigitalData.Auth.Client;
|
||||||
|
|
||||||
|
public static class DIExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddAuthHubClient(this IServiceCollection services, Action<ClientParams> options)
|
||||||
|
{
|
||||||
|
services
|
||||||
|
.Configure(options)
|
||||||
|
.AddSingleton<IAuthClient, AuthClient>()
|
||||||
|
.TryAddSingleton<HubConnectionBuilder>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user