diff --git a/src/WorkFlow.API/Program.cs b/src/WorkFlow.API/Program.cs index 646034d..6136a49 100644 --- a/src/WorkFlow.API/Program.cs +++ b/src/WorkFlow.API/Program.cs @@ -37,7 +37,11 @@ try // Add services to the container var cnn_str = config.GetConnectionString("Default") ?? throw new("Default connection string not found."); builder.Services.AddDbContext(options => options.UseSqlServer(cnn_str).EnableDetailedErrors()); - builder.Services.AddWorkFlowServices().AddWorkFlowRepositories().AddUserManager(); + var mediatRLicense = config["MediatRLicense"] + ?? throw new InvalidOperationException( + "The 'MediatRLicense' configuration value is missing or empty." + + "Please ensure it is properly set in the configuration source."); + builder.Services.AddWorkFlowServices(opt => opt.MediatRLicense = mediatRLicense).AddWorkFlowRepositories().AddUserManager(); builder.Services.AddCookieBasedLocalizer(); builder.Services.AddDirectorySearchService(config.GetSection("DirectorySearchOptions")); builder.Services.AddJWTService(user => new SecurityTokenDescriptor() diff --git a/src/WorkFlow.API/appsettings.json b/src/WorkFlow.API/appsettings.json index b3c541b..0f03928 100644 --- a/src/WorkFlow.API/appsettings.json +++ b/src/WorkFlow.API/appsettings.json @@ -80,5 +80,6 @@ "AuthClientParams": { "Url": "http://172.24.12.39:9090/auth-hub", "RetryDelay": "00:00:05" - } + }, + "MediatRLicense": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxNzg0ODUxMjAwIiwiaWF0IjoiMTc1MzM2MjQ5MSIsImFjY291bnRfaWQiOiIwMTk4M2M1OWU0YjM3MjhlYmZkMzEwM2MyYTQ4NmU4NSIsImN1c3RvbWVyX2lkIjoiY3RtXzAxazB5NmV3MmQ4YTk4Mzg3aDJnbTRuOWswIiwic3ViX2lkIjoiLSIsImVkaXRpb24iOiIwIiwidHlwZSI6IjIifQ.ZqsFG7kv_-xGfxS6ACk3i0iuNiVUXX2AvPI8iAcZ6-z2170lGv__aO32tWpQccD9LCv5931lBNLWSblKS0MT3gOt-5he2TEftwiSQGFwoIBgtOHWsNRMinUrg2trceSp3IhyS3UaMwnxZDrCvx4-0O-kpOzVpizeHUAZNr5U7oSCWO34bpKdae6grtM5e3f93Z1vs7BW_iPgItd-aLvPwApbaG9VhmBTKlQ7b4Jh64y7UXJ9mKP7Qb_Oa97oEg0oY5DPHOWTZWeE1EzORgVr2qkK2DELSHuZ_EIUhODojkClPNAKtvEl_qEjpq0HZCIvGwfCCRlKlSkQqIeZdFkiXg" } \ No newline at end of file diff --git a/src/WorkFlow.Application/DependencyInjection.cs b/src/WorkFlow.Application/DependencyInjection.cs index 08cb3f0..fcc1c2e 100644 --- a/src/WorkFlow.Application/DependencyInjection.cs +++ b/src/WorkFlow.Application/DependencyInjection.cs @@ -7,8 +7,11 @@ namespace WorkFlow.Application; public static class DependencyInjection { - public static IServiceCollection AddWorkFlowServices(this IServiceCollection services) + public static IServiceCollection AddWorkFlowServices(this IServiceCollection services, Action? options = null) { + DIOptions diOptions = new(); + options?.Invoke(diOptions); + services.AddAutoMapper(typeof(MappingProfile).Assembly); services.TryAddScoped(); services.TryAddScoped(); @@ -18,8 +21,14 @@ public static class DependencyInjection services.AddMediatR(cfg => { cfg.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly); + cfg.LicenseKey = diOptions.MediatRLicense; }); return services; } + + public class DIOptions + { + public string MediatRLicense { get; set; } = string.Empty; + } } \ No newline at end of file