diff --git a/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilderExtensions.cs b/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilderExtensions.cs index 684f31d3..6e1606c2 100644 --- a/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilderExtensions.cs +++ b/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilderExtensions.cs @@ -5,60 +5,24 @@ namespace Microsoft.Extensions.DependencyInjection; public static class IMachineBuilderExtensions { - public static IMachineBuilder AddServiceOptions( - this IMachineBuilder builder, - Action configureOptions - ) - { - builder.Services.Configure(configureOptions); - return builder; - } - public static IMachineBuilder AddServiceOptions(this IMachineBuilder builder, IConfiguration config) { builder.Services.Configure(config); return builder; } - public static IMachineBuilder AddSmtTransferEngineOptions( - this IMachineBuilder builder, - Action configureOptions - ) - { - builder.Services.Configure(configureOptions); - return builder; - } - public static IMachineBuilder AddSmtTransferEngineOptions(this IMachineBuilder builder, IConfiguration config) { builder.Services.Configure(config); return builder; } - public static IMachineBuilder AddClearMLOptions( - this IMachineBuilder builder, - Action configureOptions - ) - { - builder.Services.Configure(configureOptions); - return builder; - } - public static IMachineBuilder AddClearMLOptions(this IMachineBuilder builder, IConfiguration config) { builder.Services.Configure(config); return builder; } - public static IMachineBuilder AddDistributedReaderWriterLockOptions( - this IMachineBuilder build, - Action configureOptions - ) - { - build.Services.Configure(configureOptions); - return build; - } - public static IMachineBuilder AddDistributedReaderWriterLockOptions( this IMachineBuilder build, IConfiguration config @@ -68,45 +32,18 @@ IConfiguration config return build; } - public static IMachineBuilder AddMessageOutboxOptions( - this IMachineBuilder builder, - Action configureOptions - ) - { - builder.Services.Configure(configureOptions); - return builder; - } - public static IMachineBuilder AddMessageOutboxOptions(this IMachineBuilder builder, IConfiguration config) { builder.Services.Configure(config); return builder; } - public static IMachineBuilder AddSharedFileOptions( - this IMachineBuilder builder, - Action configureOptions - ) - { - builder.Services.Configure(configureOptions); - return builder; - } - public static IMachineBuilder AddSharedFileOptions(this IMachineBuilder builder, IConfiguration config) { builder.Services.Configure(config); return builder; } - public static IMachineBuilder AddBuildJobOptions( - this IMachineBuilder builder, - Action configureOptions - ) - { - builder.Services.Configure(configureOptions); - return builder; - } - public static IMachineBuilder AddBuildJobOptions(this IMachineBuilder builder, IConfiguration config) { builder.Services.Configure(config); @@ -116,21 +53,11 @@ public static IMachineBuilder AddBuildJobOptions(this IMachineBuilder builder, I public static IMachineBuilder AddThotSmtModel(this IMachineBuilder builder) { if (builder.Configuration is null) - return builder.AddThotSmtModel(o => { }); + throw new InvalidOperationException("Configuration is required"); else return builder.AddThotSmtModel(builder.Configuration.GetSection(ThotSmtModelOptions.Key)); } - public static IMachineBuilder AddThotSmtModel( - this IMachineBuilder builder, - Action configureOptions - ) - { - builder.Services.Configure(configureOptions); - builder.Services.AddSingleton(); - return builder; - } - public static IMachineBuilder AddThotSmtModel(this IMachineBuilder builder, IConfiguration config) { builder.Services.Configure(config); diff --git a/src/Machine/src/Serval.Machine.Shared/Configuration/IServiceCollectionExtensions.cs b/src/Machine/src/Serval.Machine.Shared/Configuration/IServiceCollectionExtensions.cs index 9ae176d8..79a0c16f 100644 --- a/src/Machine/src/Serval.Machine.Shared/Configuration/IServiceCollectionExtensions.cs +++ b/src/Machine/src/Serval.Machine.Shared/Configuration/IServiceCollectionExtensions.cs @@ -24,13 +24,7 @@ public static IMachineBuilder AddMachine(this IServiceCollection services, IConf var builder = new MachineBuilder(services, configuration); if (configuration is null) { - builder.AddServiceOptions(o => { }); - builder.AddSharedFileOptions(o => { }); - builder.AddSmtTransferEngineOptions(o => { }); - builder.AddClearMLOptions(o => { }); - builder.AddDistributedReaderWriterLockOptions(o => { }); - builder.AddBuildJobOptions(o => { }); - builder.AddMessageOutboxOptions(o => { }); + throw new InvalidOperationException("Configuration is required"); } else { diff --git a/src/Serval/src/Serval.Assessment/Configuration/IServalBuilderExtensions.cs b/src/Serval/src/Serval.Assessment/Configuration/IServalBuilderExtensions.cs index d770433d..d4545ef6 100644 --- a/src/Serval/src/Serval.Assessment/Configuration/IServalBuilderExtensions.cs +++ b/src/Serval/src/Serval.Assessment/Configuration/IServalBuilderExtensions.cs @@ -5,12 +5,11 @@ namespace Microsoft.Extensions.DependencyInjection; public static class IServalBuilderExtensions { - public static IServalBuilder AddAssessment(this IServalBuilder builder, Action? configure = null) + public static IServalBuilder AddAssessment(this IServalBuilder builder) { if (builder.Configuration is null) { - builder.AddApiOptions(o => { }); - builder.AddDataFileOptions(o => { }); + throw new InvalidOperationException("Configuration is required"); } else { @@ -24,8 +23,6 @@ public static IServalBuilder AddAssessment(this IServalBuilder builder, Action { }); + throw new InvalidOperationException("Configuration is required"); else builder.AddDataFileOptions(builder.Configuration.GetSection(DataFileOptions.Key)); diff --git a/src/Serval/src/Serval.Shared/Configuration/IServalBuilderExtensions.cs b/src/Serval/src/Serval.Shared/Configuration/IServalBuilderExtensions.cs index 2f226ab4..4b4a15ba 100644 --- a/src/Serval/src/Serval.Shared/Configuration/IServalBuilderExtensions.cs +++ b/src/Serval/src/Serval.Shared/Configuration/IServalBuilderExtensions.cs @@ -2,27 +2,12 @@ public static class IServalBuilderExtensions { - public static IServalBuilder AddDataFileOptions( - this IServalBuilder builder, - Action configureOptions - ) - { - builder.Services.Configure(configureOptions); - return builder; - } - public static IServalBuilder AddDataFileOptions(this IServalBuilder builder, IConfiguration config) { builder.Services.Configure(config); return builder; } - public static IServalBuilder AddApiOptions(this IServalBuilder builder, Action configureOptions) - { - builder.Services.Configure(configureOptions); - return builder; - } - public static IServalBuilder AddApiOptions(this IServalBuilder builder, IConfiguration config) { builder.Services.Configure(config); diff --git a/src/Serval/src/Serval.Translation/Configuration/IServalBuilderExtensions.cs b/src/Serval/src/Serval.Translation/Configuration/IServalBuilderExtensions.cs index 190d627f..63610b5e 100644 --- a/src/Serval/src/Serval.Translation/Configuration/IServalBuilderExtensions.cs +++ b/src/Serval/src/Serval.Translation/Configuration/IServalBuilderExtensions.cs @@ -5,15 +5,11 @@ namespace Microsoft.Extensions.DependencyInjection; public static class IServalBuilderExtensions { - public static IServalBuilder AddTranslation( - this IServalBuilder builder, - Action? configure = null - ) + public static IServalBuilder AddTranslation(this IServalBuilder builder) { if (builder.Configuration is null) { - builder.AddApiOptions(o => { }); - builder.AddDataFileOptions(o => { }); + throw new InvalidOperationException("Configuration is required"); } else { @@ -27,8 +23,6 @@ public static IServalBuilder AddTranslation( var translationOptions = new TranslationOptions(); builder.Configuration?.GetSection(TranslationOptions.Key).Bind(translationOptions); - if (configure is not null) - configure(translationOptions); foreach (EngineInfo engine in translationOptions.Engines) {