2024-09-18 20:40:12 +00:00
|
|
|
|
using Dalamud.Plugin.Services;
|
|
|
|
|
using JetBrains.Annotations;
|
2024-06-09 14:30:53 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Questionable.Controller.Steps;
|
|
|
|
|
|
|
|
|
|
namespace Questionable;
|
|
|
|
|
|
|
|
|
|
internal static class ServiceCollectionExtensions
|
|
|
|
|
{
|
2024-08-20 00:48:06 +00:00
|
|
|
|
public static void AddTaskFactory<
|
2024-09-18 20:40:12 +00:00
|
|
|
|
[MeansImplicitUse(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
|
|
|
|
|
TFactory>(
|
2024-06-09 14:30:53 +00:00
|
|
|
|
this IServiceCollection serviceCollection)
|
|
|
|
|
where TFactory : class, ITaskFactory
|
|
|
|
|
{
|
|
|
|
|
serviceCollection.AddSingleton<ITaskFactory, TFactory>();
|
2024-08-20 00:48:06 +00:00
|
|
|
|
serviceCollection.AddSingleton<TFactory>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
}
|
2024-09-18 20:40:12 +00:00
|
|
|
|
|
|
|
|
|
public static void AddTaskExecutor<T,
|
|
|
|
|
[MeansImplicitUse(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
|
|
|
|
|
TExecutor>(
|
|
|
|
|
this IServiceCollection serviceCollection)
|
|
|
|
|
where T : class, ITask
|
|
|
|
|
where TExecutor : TaskExecutor<T>
|
|
|
|
|
{
|
|
|
|
|
serviceCollection.AddKeyedTransient<ITaskExecutor, TExecutor>(typeof(T));
|
|
|
|
|
serviceCollection.AddTransient<TExecutor>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void AddTaskFactoryAndExecutor<T,
|
|
|
|
|
[MeansImplicitUse(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
|
|
|
|
|
TFactory,
|
|
|
|
|
[MeansImplicitUse(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
|
|
|
|
|
TExecutor>(
|
|
|
|
|
this IServiceCollection serviceCollection)
|
|
|
|
|
where TFactory : class, ITaskFactory
|
|
|
|
|
where T : class, ITask
|
|
|
|
|
where TExecutor : TaskExecutor<T>
|
|
|
|
|
{
|
|
|
|
|
serviceCollection.AddTaskFactory<TFactory>();
|
|
|
|
|
serviceCollection.AddTaskExecutor<T, TExecutor>();
|
|
|
|
|
}
|
2024-06-09 14:30:53 +00:00
|
|
|
|
}
|