diff --git a/Source/Boxed.AspNetCore/Boxed.AspNetCore.csproj b/Source/Boxed.AspNetCore/Boxed.AspNetCore.csproj index 95c7742a..5e1c8cdd 100644 --- a/Source/Boxed.AspNetCore/Boxed.AspNetCore.csproj +++ b/Source/Boxed.AspNetCore/Boxed.AspNetCore.csproj @@ -9,7 +9,7 @@ - 2.1.0 + 2.2.0 Muhammad Rehan Saeed (RehanSaeed.com) ASP.NET Core Framework Boxed Provides ASP.NET Core middleware, MVC filters, extension methods and helper code for an ASP.NET Core project. @@ -45,6 +45,7 @@ + diff --git a/Source/Boxed.AspNetCore/ServiceCollectionExtensions.cs b/Source/Boxed.AspNetCore/ServiceCollectionExtensions.cs index 9260bd7a..9d07a492 100644 --- a/Source/Boxed.AspNetCore/ServiceCollectionExtensions.cs +++ b/Source/Boxed.AspNetCore/ServiceCollectionExtensions.cs @@ -1,7 +1,9 @@ namespace Boxed.AspNetCore { using System; + using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Options; /// /// extension methods. @@ -57,5 +59,20 @@ public static class ServiceCollectionExtensions return services; } + + /// + /// Registers and to the services container. + /// + /// The type of the options. + /// The services collection. + /// The configuration. + /// The same services collection. + public static IServiceCollection AddOptions( + this IServiceCollection services, + IConfiguration configuration) + where TOptions : class, new() => + services + .Configure(configuration) + .AddSingleton(x => x.GetRequiredService>().Value); } } diff --git a/Tests/Boxed.AspNetCore.Swagger.Test/Boxed.AspNetCore.Swagger.Test.csproj b/Tests/Boxed.AspNetCore.Swagger.Test/Boxed.AspNetCore.Swagger.Test.csproj index e8b3df52..fab287a2 100644 --- a/Tests/Boxed.AspNetCore.Swagger.Test/Boxed.AspNetCore.Swagger.Test.csproj +++ b/Tests/Boxed.AspNetCore.Swagger.Test/Boxed.AspNetCore.Swagger.Test.csproj @@ -21,7 +21,7 @@ - + diff --git a/Tests/Boxed.AspNetCore.TagHelpers.Test/Boxed.AspNetCore.TagHelpers.Test.csproj b/Tests/Boxed.AspNetCore.TagHelpers.Test/Boxed.AspNetCore.TagHelpers.Test.csproj index 42cafc24..d6e45504 100644 --- a/Tests/Boxed.AspNetCore.TagHelpers.Test/Boxed.AspNetCore.TagHelpers.Test.csproj +++ b/Tests/Boxed.AspNetCore.TagHelpers.Test/Boxed.AspNetCore.TagHelpers.Test.csproj @@ -14,7 +14,7 @@ - + diff --git a/Tests/Boxed.AspNetCore.Test/Boxed.AspNetCore.Test.csproj b/Tests/Boxed.AspNetCore.Test/Boxed.AspNetCore.Test.csproj index 90cf9b75..e2ad4f6f 100644 --- a/Tests/Boxed.AspNetCore.Test/Boxed.AspNetCore.Test.csproj +++ b/Tests/Boxed.AspNetCore.Test/Boxed.AspNetCore.Test.csproj @@ -15,7 +15,7 @@ - + diff --git a/Tests/Boxed.Mapping.Test/Boxed.Mapping.Test.csproj b/Tests/Boxed.Mapping.Test/Boxed.Mapping.Test.csproj index 8a535f61..29cef639 100644 --- a/Tests/Boxed.Mapping.Test/Boxed.Mapping.Test.csproj +++ b/Tests/Boxed.Mapping.Test/Boxed.Mapping.Test.csproj @@ -13,7 +13,7 @@ - +