From 145901d0efd5858ecea0938e4ec3f7c888d456ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 8 Apr 2018 20:58:20 +0300 Subject: [PATCH] Added GetHostingEnvironment and GetConfiguration extension methods. --- .../Volo.Abp.AspNetCore.EmbeddedFiles.csproj | 3 +-- .../Hosting/AbpHostingEnvironmentExtensions.cs | 17 +++++++++++++++++ .../AbpAspNetCoreServiceCollectionExtensions.cs | 12 ++++++++++++ .../Volo.Abp.AspNetCore.csproj | 1 + 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Hosting/AbpHostingEnvironmentExtensions.cs create mode 100644 src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/AbpAspNetCoreServiceCollectionExtensions.cs diff --git a/src/Volo.Abp.AspNetCore.EmbeddedFiles/Volo.Abp.AspNetCore.EmbeddedFiles.csproj b/src/Volo.Abp.AspNetCore.EmbeddedFiles/Volo.Abp.AspNetCore.EmbeddedFiles.csproj index 7adca56b1b..03db7c46e2 100644 --- a/src/Volo.Abp.AspNetCore.EmbeddedFiles/Volo.Abp.AspNetCore.EmbeddedFiles.csproj +++ b/src/Volo.Abp.AspNetCore.EmbeddedFiles/Volo.Abp.AspNetCore.EmbeddedFiles.csproj @@ -19,8 +19,7 @@ - - + diff --git a/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Hosting/AbpHostingEnvironmentExtensions.cs b/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Hosting/AbpHostingEnvironmentExtensions.cs new file mode 100644 index 0000000000..53609367c7 --- /dev/null +++ b/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Hosting/AbpHostingEnvironmentExtensions.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.Configuration; + +namespace Microsoft.AspNetCore.Hosting +{ + public static class AbpHostingEnvironmentExtensions + { + public static IConfigurationRoot GetConfiguration(IHostingEnvironment env, string fileName = "appsettings") + { + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath) + .AddJsonFile(fileName + ".json", optional: false, reloadOnChange: true) + .AddJsonFile($"{fileName}.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); + + return builder.Build(); + } + } +} diff --git a/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/AbpAspNetCoreServiceCollectionExtensions.cs b/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/AbpAspNetCoreServiceCollectionExtensions.cs new file mode 100644 index 0000000000..fe755e78c4 --- /dev/null +++ b/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/AbpAspNetCoreServiceCollectionExtensions.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Hosting; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class AbpAspNetCoreServiceCollectionExtensions + { + public static IHostingEnvironment GetHostingEnvironment(IServiceCollection services) + { + return services.GetSingletonInstance(); + } + } +} diff --git a/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj b/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj index 7df2b2b04e..0120ecd02e 100644 --- a/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj +++ b/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj @@ -23,6 +23,7 @@ +