27 lines
1.0 KiB
C#
27 lines
1.0 KiB
C#
using Microsoft.Extensions.Options;
|
|
|
|
namespace MxGateway.Server.Galaxy;
|
|
|
|
public static class GalaxyRepositoryServiceCollectionExtensions
|
|
{
|
|
/// <summary>Registers Galaxy Repository services in the dependency injection container.</summary>
|
|
/// <param name="services">The service collection.</param>
|
|
/// <returns>The service collection for chaining.</returns>
|
|
public static IServiceCollection AddGalaxyRepository(this IServiceCollection services)
|
|
{
|
|
services
|
|
.AddOptions<GalaxyRepositoryOptions>()
|
|
.BindConfiguration(GalaxyRepositoryOptions.SectionName)
|
|
.ValidateOnStart();
|
|
|
|
services.AddSingleton(sp =>
|
|
new GalaxyRepository(sp.GetRequiredService<IOptions<GalaxyRepositoryOptions>>().Value));
|
|
|
|
services.AddSingleton<IGalaxyDeployNotifier, GalaxyDeployNotifier>();
|
|
services.AddSingleton<IGalaxyHierarchyCache, GalaxyHierarchyCache>();
|
|
services.AddHostedService<GalaxyHierarchyRefreshService>();
|
|
|
|
return services;
|
|
}
|
|
}
|