using Microsoft.Extensions.Options;
namespace MxGateway.Server.Galaxy;
public static class GalaxyRepositoryServiceCollectionExtensions
{
/// Registers Galaxy Repository services in the dependency injection container.
/// The service collection.
/// The service collection for chaining.
public static IServiceCollection AddGalaxyRepository(this IServiceCollection services)
{
services
.AddOptions()
.BindConfiguration(GalaxyRepositoryOptions.SectionName)
.ValidateOnStart();
services.AddSingleton(sp =>
new GalaxyRepository(sp.GetRequiredService>().Value));
services.AddSingleton();
services.AddSingleton();
services.AddHostedService();
return services;
}
}