using Elsa.Liquid.Contracts;
using Elsa.Liquid.Options;
using Elsa.Liquid.Services;
// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection;
public static class DependencyInjectionExtensions
{
///
/// Register a custom Liquid filter.
///
public static IServiceCollection AddLiquidFilter(this IServiceCollection services, string name) where T : class, ILiquidFilter
{
services.Configure(options => options.FilterRegistrations[name] = typeof(T));
services.AddScoped();
return services;
}
///
/// Register a custom Liquid tag.
///
public static IServiceCollection RegisterLiquidTag(this IServiceCollection services, Action configure)
{
services.Configure(options => options.ParserConfiguration.Add(configure));
return services;
}
///
/// Enables access to .NET configuration via the Configuration keyword.
/// Do not enable this option if you execute user supplied (or otherwise untrusted) workflows.
///
public static IServiceCollection EnableLiquidConfigurationAccess(this IServiceCollection services)
{
services.Configure(options => options.AllowConfigurationAccess = true);
return services;
}
}