using Microsoft.Extensions.DependencyInjection;
namespace FrameworkBLL.GOP.Transform
{
///
/// Extension methods for registering ITransformExpression implementations.
///
/// Usage in Program.cs (or wherever SL DI is configured):
///
/// builder.Services.AddMappingTransforms(); // registers all built-in transforms
/// builder.Services.AddTransformExpression<MyCustomTransform>(); // add a custom one
///
/// Built-in transforms registered by AddMappingTransforms():
/// UPPER, LOWER, TRIM, NULL_TO_EMPTY, CONST, ROUND, FORMAT_DATE, TO_NUMBER, TO_DATETIME
///
public static class TransformExpressionExtensions
{
/// Registers a single ITransformExpression implementation as Singleton.
public static IServiceCollection AddTransformExpression(this IServiceCollection services)
where T : class, ITransformExpression
{
services.AddSingleton();
return services;
}
///
/// Registers all built-in ITransformExpression implementations.
/// Call this once from Program.cs in any SL project that uses the mapping engine.
///
public static IServiceCollection AddMappingTransforms(this IServiceCollection services)
{
services
.AddTransformExpression()
.AddTransformExpression()
.AddTransformExpression()
.AddTransformExpression()
.AddTransformExpression()
.AddTransformExpression()
.AddTransformExpression()
.AddTransformExpression()
.AddTransformExpression();
return services;
}
}
}