diff --git a/src/ReC.Application/DependencyInjection.cs b/src/ReC.Application/DependencyInjection.cs new file mode 100644 index 0000000..68a3e35 --- /dev/null +++ b/src/ReC.Application/DependencyInjection.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.DependencyInjection; +using System.Reflection; + +namespace ReC.Application; + +public static class DependencyInjection +{ + public static IServiceCollection AddRecServices(this IServiceCollection services, Action options) + { + var configOpt = new ConfigurationOptions(); + options.Invoke(configOpt); + + services.AddAutoMapper(cfg => + { + cfg.AddMaps(Assembly.GetExecutingAssembly()); + cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey; + }); + + services.AddMediatR(cfg => + { + cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()); + cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey; + }); + + return services; + } + + public class ConfigurationOptions + { + public string LuckyPennySoftwareLicenseKey { get; set; } = string.Empty; + } +}