using Artemis.WebClient.Workshop.Repositories;
using Artemis.WebClient.Workshop.Services;
using DryIoc;
using DryIoc.Microsoft.DependencyInjection;
using IdentityModel.Client;
using Microsoft.Extensions.DependencyInjection;
namespace Artemis.WebClient.Workshop.DryIoc;
///
/// Provides an extension method to register services onto a DryIoc .
///
public static class ContainerExtensions
{
///
/// Registers the updating client into the container.
///
/// The builder building the current container
public static void RegisterWorkshopClient(this IContainer container)
{
ServiceCollection serviceCollection = new();
serviceCollection
.AddHttpClient()
.AddWorkshopClient()
.ConfigureHttpClient(client => client.BaseAddress = new Uri("https://localhost:7281/graphql"));
serviceCollection.AddSingleton(r =>
{
IHttpClientFactory factory = r.GetRequiredService();
return new DiscoveryCache(IAuthenticationService.AUTHORITY, () => factory.CreateClient());
});
container.WithDependencyInjectionAdapter(serviceCollection);
container.Register(Reuse.Singleton);
container.Register(Reuse.Singleton);
}
}