diff --git a/Oqtane.Server/Extensions/OqtaneMvcBuilderExtensions.cs b/Oqtane.Server/Extensions/OqtaneMvcBuilderExtensions.cs index 948e1120..61a3103c 100644 --- a/Oqtane.Server/Extensions/OqtaneMvcBuilderExtensions.cs +++ b/Oqtane.Server/Extensions/OqtaneMvcBuilderExtensions.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationParts; @@ -8,6 +9,11 @@ namespace Microsoft.Extensions.DependencyInjection { public static IMvcBuilder AddOqtaneApplicationParts(this IMvcBuilder mvcBuilder) { + if (mvcBuilder is null) + { + throw new ArgumentNullException(nameof(mvcBuilder)); + } + // load MVC application parts from module assemblies foreach (var assembly in OqtaneServiceCollectionExtensions.GetOqtaneModuleAssemblies()) { diff --git a/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs b/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs index bbde6cde..2eec6534 100644 --- a/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs +++ b/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs @@ -20,6 +20,11 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOqtaneModules(this IServiceCollection services) { + if (services is null) + { + throw new ArgumentNullException(nameof(services)); + } + LoadAssemblies("Module"); return services; @@ -27,6 +32,11 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOqtaneThemes(this IServiceCollection services) { + if (services is null) + { + throw new ArgumentNullException(nameof(services)); + } + LoadAssemblies("Theme"); return services; @@ -34,6 +44,11 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOqtaneServices(this IServiceCollection services) { + if (services is null) + { + throw new ArgumentNullException(nameof(services)); + } + // dynamically register module services, contexts, and repository classes var assemblies = Assemblies. Where(item => item.FullName.StartsWith("Oqtane.") || item.FullName.Contains(".Module.")).ToArray(); @@ -52,6 +67,11 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOqtaneHostedServices(this IServiceCollection services) { + if (services is null) + { + throw new ArgumentNullException(nameof(services)); + } + // dynamically register hosted services var hostedServiceType = typeof(IHostedService); foreach (var assembly in Assemblies)