26 lines
822 B
C#
26 lines
822 B
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using StellaOps.DependencyInjection;
|
|
using StellaOps.DependencyInjection.Validation;
|
|
|
|
namespace StellaOps.Plugin.MyJob;
|
|
|
|
/// <summary>
|
|
/// Registers MyJob services with the dependency injection container.
|
|
/// </summary>
|
|
public sealed class MyJobDependencyInjectionRoutine : IDependencyInjectionRoutine
|
|
{
|
|
/// <inheritdoc />
|
|
public IServiceCollection Register(IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
// Register options with fail-fast validation
|
|
services.AddOptionsWithValidation<MyJobOptions, MyJobOptionsValidator>(
|
|
MyJobOptions.SectionName);
|
|
|
|
// Register the scheduled job
|
|
services.AddSingleton<IScheduledJob, MyJob>();
|
|
|
|
return services;
|
|
}
|
|
}
|