24 lines
707 B
C#
24 lines
707 B
C#
using BackgroundJobs.Task.Jobs;
|
|
|
|
namespace BackgroundJobs.Task;
|
|
|
|
public class JobsBootstrapper
|
|
{
|
|
public static void Configure(IServiceCollection services)
|
|
{
|
|
var currentNamespace = typeof(JobSchedulerRegistrator).Namespace; // همون namespace کلاس
|
|
|
|
var assembly = typeof(JobSchedulerRegistrator).Assembly;
|
|
|
|
var jobTypes = assembly.GetTypes()
|
|
.Where(t =>
|
|
t is { IsClass: true, IsAbstract: false, Namespace: not null } &&
|
|
t.Namespace.StartsWith(currentNamespace, StringComparison.Ordinal))
|
|
.ToList();
|
|
|
|
foreach (var jobType in jobTypes)
|
|
{
|
|
services.AddTransient(jobType);
|
|
}
|
|
}
|
|
} |