From d873be97d882e1a39b07c097255f39979e6f882a Mon Sep 17 00:00:00 2001 From: tparnell Date: Sat, 2 Feb 2019 14:17:20 -0500 Subject: [PATCH] bettah config --- .vscode/launch.json | 17 ++++++++--------- .vscode/tasks.json | 2 +- src/TerribleDev.Blog.Web/Startup.cs | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 72cf05c..ed88a45 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,18 +1,17 @@ { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md - "version": "0.2.0", - "configurations": [ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ { "name": ".NET Core Launch (web)", "type": "coreclr", "request": "launch", "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/TerribleDev.Blog.Web/bin/Debug/netcoreapp2.2/TerribleDev.Blog.Web.dll", + "program": "${workspaceFolder}/src/TerribleDev.Blog.Web/bin/Debug/netcoreapp2.2/TerribleDev.Blog.Web.dll", "args": [], - "cwd": "${workspaceFolder}/TerribleDev.Blog.Web", + "cwd": "${workspaceFolder}/src/TerribleDev.Blog.Web", "stopAtEntry": false, "internalConsoleOptions": "openOnSessionStart", "launchBrowser": { @@ -42,5 +41,5 @@ "request": "attach", "processId": "${command:pickProcess}" } - ,] + ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9d89ffe..2b93d09 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,7 +7,7 @@ "type": "process", "args": [ "build", - "${workspaceFolder}/TerribleDev.Blog.Web/TerribleDev.Blog.Web.csproj" + "${workspaceFolder}/src/TerribleDev.Blog.Web/TerribleDev.Blog.Web.csproj" ], "problemMatcher": "$msCompile" } diff --git a/src/TerribleDev.Blog.Web/Startup.cs b/src/TerribleDev.Blog.Web/Startup.cs index 80ebfcf..ecfa2ab 100644 --- a/src/TerribleDev.Blog.Web/Startup.cs +++ b/src/TerribleDev.Blog.Web/Startup.cs @@ -21,19 +21,27 @@ namespace TerribleDev.Blog.Web { public class Startup { - public Startup(IConfiguration configuration) + public Startup(IConfiguration configuration, IHostingEnvironment env) { Configuration = configuration; + Env = env; } public IConfiguration Configuration { get; } + public IHostingEnvironment Env { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - var blogConfig = new BlogConfiguration(); - Configuration.GetSection("Blog").Bind(blogConfig); - services.AddSingleton(blogConfig); + Func getBlog = () => Configuration.GetSection("Blog").Get(); + if(Env.IsDevelopment()) + { + services.AddTransient(a => getBlog()); + } + else + { + services.AddSingleton(getBlog()); + } services.AddResponseCompression(a => { a.EnableForHttps = true;