using Microsoft.Extensions.DependencyInjection;
using System.Threading.Channels;
namespace Prefab.Data.Seeder;
public static class Extensions
{
///
/// Registers a seeder and its options so it can participate in environment-aware execution.
///
/// Seeder implementation.
/// The host service collection.
/// Determines when the seeder is allowed to run.
/// The provided service collection.
public static IServiceCollection AddSeeder(this IServiceCollection services, RunMode runMode = RunMode.RunOnFirstLoadOnly) where TSeeder : class, ISeeder
{
services.AddScoped();
services.AddScoped();
services.Configure>(opts => opts.RunMode = runMode);
return services;
}
///
/// Gets the channel used to queue seeder operations for background execution.
///
public static Channel> Channel { get; }
= System.Threading.Channels.Channel.CreateUnbounded>();
}