diff --git a/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilder.cs b/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilder.cs index f8dfbcd5..ce0180b5 100644 --- a/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilder.cs +++ b/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilder.cs @@ -3,5 +3,5 @@ public interface IMachineBuilder { IServiceCollection Services { get; } - IConfiguration? Configuration { get; } + IConfiguration Configuration { get; } } diff --git a/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilderExtensions.cs b/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilderExtensions.cs index 6e1606c2..df8b8228 100644 --- a/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilderExtensions.cs +++ b/src/Machine/src/Serval.Machine.Shared/Configuration/IMachineBuilderExtensions.cs @@ -52,10 +52,7 @@ public static IMachineBuilder AddBuildJobOptions(this IMachineBuilder builder, I public static IMachineBuilder AddThotSmtModel(this IMachineBuilder builder) { - if (builder.Configuration is null) - throw new InvalidOperationException("Configuration is required"); - else - return builder.AddThotSmtModel(builder.Configuration.GetSection(ThotSmtModelOptions.Key)); + return builder.AddThotSmtModel(builder.Configuration.GetSection(ThotSmtModelOptions.Key)); } public static IMachineBuilder AddThotSmtModel(this IMachineBuilder builder, IConfiguration config) diff --git a/src/Machine/src/Serval.Machine.Shared/Configuration/IServiceCollectionExtensions.cs b/src/Machine/src/Serval.Machine.Shared/Configuration/IServiceCollectionExtensions.cs index 79a0c16f..c72302b9 100644 --- a/src/Machine/src/Serval.Machine.Shared/Configuration/IServiceCollectionExtensions.cs +++ b/src/Machine/src/Serval.Machine.Shared/Configuration/IServiceCollectionExtensions.cs @@ -2,7 +2,7 @@ public static class IServiceCollectionExtensions { - public static IMachineBuilder AddMachine(this IServiceCollection services, IConfiguration? configuration = null) + public static IMachineBuilder AddMachine(this IServiceCollection services, IConfiguration configuration) { if (!Sldr.IsInitialized) Sldr.Initialize(); @@ -22,22 +22,13 @@ public static IMachineBuilder AddMachine(this IServiceCollection services, IConf ); var builder = new MachineBuilder(services, configuration); - if (configuration is null) - { - throw new InvalidOperationException("Configuration is required"); - } - else - { - builder.AddServiceOptions(configuration.GetSection(ServiceOptions.Key)); - builder.AddSharedFileOptions(configuration.GetSection(SharedFileOptions.Key)); - builder.AddSmtTransferEngineOptions(configuration.GetSection(SmtTransferEngineOptions.Key)); - builder.AddClearMLOptions(configuration.GetSection(ClearMLOptions.Key)); - builder.AddDistributedReaderWriterLockOptions( - configuration.GetSection(DistributedReaderWriterLockOptions.Key) - ); - builder.AddBuildJobOptions(configuration.GetSection(BuildJobOptions.Key)); - builder.AddMessageOutboxOptions(configuration.GetSection(MessageOutboxOptions.Key)); - } + builder.AddServiceOptions(configuration.GetSection(ServiceOptions.Key)); + builder.AddSharedFileOptions(configuration.GetSection(SharedFileOptions.Key)); + builder.AddSmtTransferEngineOptions(configuration.GetSection(SmtTransferEngineOptions.Key)); + builder.AddClearMLOptions(configuration.GetSection(ClearMLOptions.Key)); + builder.AddDistributedReaderWriterLockOptions(configuration.GetSection(DistributedReaderWriterLockOptions.Key)); + builder.AddBuildJobOptions(configuration.GetSection(BuildJobOptions.Key)); + builder.AddMessageOutboxOptions(configuration.GetSection(MessageOutboxOptions.Key)); return builder; } diff --git a/src/Machine/src/Serval.Machine.Shared/Configuration/MachineBuilder.cs b/src/Machine/src/Serval.Machine.Shared/Configuration/MachineBuilder.cs index 58ddf5c1..5fece454 100644 --- a/src/Machine/src/Serval.Machine.Shared/Configuration/MachineBuilder.cs +++ b/src/Machine/src/Serval.Machine.Shared/Configuration/MachineBuilder.cs @@ -1,7 +1,7 @@ namespace Microsoft.Extensions.DependencyInjection; -internal class MachineBuilder(IServiceCollection services, IConfiguration? configuration) : IMachineBuilder +internal class MachineBuilder(IServiceCollection services, IConfiguration configuration) : IMachineBuilder { public IServiceCollection Services { get; } = services; - public IConfiguration? Configuration { get; } = configuration; + public IConfiguration Configuration { get; } = configuration; } diff --git a/src/Serval/src/Serval.Assessment/Configuration/IServalBuilderExtensions.cs b/src/Serval/src/Serval.Assessment/Configuration/IServalBuilderExtensions.cs index d4545ef6..ef40b2bd 100644 --- a/src/Serval/src/Serval.Assessment/Configuration/IServalBuilderExtensions.cs +++ b/src/Serval/src/Serval.Assessment/Configuration/IServalBuilderExtensions.cs @@ -7,15 +7,8 @@ public static class IServalBuilderExtensions { public static IServalBuilder AddAssessment(this IServalBuilder builder) { - if (builder.Configuration is null) - { - throw new InvalidOperationException("Configuration is required"); - } - else - { - builder.AddApiOptions(builder.Configuration.GetSection(ApiOptions.Key)); - builder.AddDataFileOptions(builder.Configuration.GetSection(DataFileOptions.Key)); - } + builder.AddApiOptions(builder.Configuration.GetSection(ApiOptions.Key)); + builder.AddDataFileOptions(builder.Configuration.GetSection(DataFileOptions.Key)); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/src/Serval/src/Serval.DataFiles/Configuration/IServalBuilderExtensions.cs b/src/Serval/src/Serval.DataFiles/Configuration/IServalBuilderExtensions.cs index 69982782..11af65e1 100644 --- a/src/Serval/src/Serval.DataFiles/Configuration/IServalBuilderExtensions.cs +++ b/src/Serval/src/Serval.DataFiles/Configuration/IServalBuilderExtensions.cs @@ -4,10 +4,7 @@ public static class IServalBuilderExtensions { public static IServalBuilder AddDataFiles(this IServalBuilder builder) { - if (builder.Configuration is null) - throw new InvalidOperationException("Configuration is required"); - else - builder.AddDataFileOptions(builder.Configuration.GetSection(DataFileOptions.Key)); + builder.AddDataFileOptions(builder.Configuration.GetSection(DataFileOptions.Key)); builder.Services.AddScoped(); builder.Services.AddHostedService(); diff --git a/src/Serval/src/Serval.Shared/Configuration/IServalBuilder.cs b/src/Serval/src/Serval.Shared/Configuration/IServalBuilder.cs index 116fc6d4..f37283e3 100644 --- a/src/Serval/src/Serval.Shared/Configuration/IServalBuilder.cs +++ b/src/Serval/src/Serval.Shared/Configuration/IServalBuilder.cs @@ -3,5 +3,5 @@ public interface IServalBuilder { IServiceCollection Services { get; } - IConfiguration? Configuration { get; } + IConfiguration Configuration { get; } } diff --git a/src/Serval/src/Serval.Shared/Configuration/IServiceCollectionExtensions.cs b/src/Serval/src/Serval.Shared/Configuration/IServiceCollectionExtensions.cs index 2671ac40..3a7ce339 100644 --- a/src/Serval/src/Serval.Shared/Configuration/IServiceCollectionExtensions.cs +++ b/src/Serval/src/Serval.Shared/Configuration/IServiceCollectionExtensions.cs @@ -2,7 +2,7 @@ public static class IServiceCollectionExtensions { - public static IServalBuilder AddServal(this IServiceCollection services, IConfiguration? configuration = null) + public static IServalBuilder AddServal(this IServiceCollection services, IConfiguration configuration) { services.AddTransient(); services.AddTransient(); diff --git a/src/Serval/src/Serval.Shared/Configuration/ServalBuilder.cs b/src/Serval/src/Serval.Shared/Configuration/ServalBuilder.cs index b4fe3747..48c5123d 100644 --- a/src/Serval/src/Serval.Shared/Configuration/ServalBuilder.cs +++ b/src/Serval/src/Serval.Shared/Configuration/ServalBuilder.cs @@ -1,7 +1,7 @@ namespace Microsoft.Extensions.DependencyInjection; -internal class ServalBuilder(IServiceCollection services, IConfiguration? configuration) : IServalBuilder +internal class ServalBuilder(IServiceCollection services, IConfiguration configuration) : IServalBuilder { public IServiceCollection Services { get; } = services; - public IConfiguration? Configuration { get; } = configuration; + public IConfiguration Configuration { get; } = configuration; } diff --git a/src/Serval/src/Serval.Translation/Configuration/IServalBuilderExtensions.cs b/src/Serval/src/Serval.Translation/Configuration/IServalBuilderExtensions.cs index 63610b5e..3378e60d 100644 --- a/src/Serval/src/Serval.Translation/Configuration/IServalBuilderExtensions.cs +++ b/src/Serval/src/Serval.Translation/Configuration/IServalBuilderExtensions.cs @@ -7,15 +7,8 @@ public static class IServalBuilderExtensions { public static IServalBuilder AddTranslation(this IServalBuilder builder) { - if (builder.Configuration is null) - { - throw new InvalidOperationException("Configuration is required"); - } - else - { - builder.AddApiOptions(builder.Configuration.GetSection(ApiOptions.Key)); - builder.AddDataFileOptions(builder.Configuration.GetSection(DataFileOptions.Key)); - } + builder.AddApiOptions(builder.Configuration.GetSection(ApiOptions.Key)); + builder.AddDataFileOptions(builder.Configuration.GetSection(DataFileOptions.Key)); builder.Services.AddScoped(); builder.Services.AddScoped();