2022-05-26 10:47:31 +00:00
|
|
|
using System;
|
2022-05-27 10:36:39 +00:00
|
|
|
using Elsa.Features;
|
|
|
|
|
using Elsa.Features.Extensions;
|
|
|
|
|
using Elsa.Features.Services;
|
2022-05-26 10:47:31 +00:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace Elsa.Extensions;
|
|
|
|
|
|
|
|
|
|
public static class DependencyInjectionExtensions
|
|
|
|
|
{
|
2022-05-27 10:36:39 +00:00
|
|
|
public static IServiceCollection AddElsa(this IServiceCollection services, Action<IModule>? configure = default)
|
2022-05-26 10:47:31 +00:00
|
|
|
{
|
|
|
|
|
var serviceConfiguration = services.ConfigureElsa();
|
|
|
|
|
configure?.Invoke(serviceConfiguration);
|
|
|
|
|
serviceConfiguration.Apply();
|
|
|
|
|
return services;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-27 10:36:39 +00:00
|
|
|
public static IModule ConfigureElsa(this IServiceCollection services)
|
2022-05-26 10:47:31 +00:00
|
|
|
{
|
2022-05-27 10:36:39 +00:00
|
|
|
var module = services.CreateModule();
|
|
|
|
|
module.Configure<ElsaFeature>();
|
2022-05-26 10:47:31 +00:00
|
|
|
|
2022-05-27 10:36:39 +00:00
|
|
|
return module;
|
2022-05-26 10:47:31 +00:00
|
|
|
}
|
|
|
|
|
}
|