From 4267d9b25fe397ce1fa6eda91a552401a7022d0a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 20 Nov 2014 18:13:03 -0800 Subject: [PATCH] React to hosting changes --- src/MusicStore/Program.cs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/MusicStore/Program.cs b/src/MusicStore/Program.cs index ff32e728f2..0d086e2e3f 100644 --- a/src/MusicStore/Program.cs +++ b/src/MusicStore/Program.cs @@ -1,9 +1,11 @@ -using Microsoft.Framework.ConfigurationModel; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNet.Hosting; +using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection.Fallback; -using Microsoft.AspNet.Hosting; -using System; -using System.Threading.Tasks; +using Microsoft.Framework.Runtime; namespace MusicStore { @@ -26,10 +28,9 @@ namespace MusicStore var config = new Configuration(); config.AddCommandLine(args); - var serviceCollection = new ServiceCollection(); - serviceCollection.Add(HostingServices.GetDefaultServices(config)); - serviceCollection.AddInstance(new HostingEnvironment() { WebRoot = "wwwroot" }); - var services = serviceCollection.BuildServiceProvider(_hostServiceProvider); + var serviceCollection = HostingServices.Create(_hostServiceProvider); + serviceCollection.AddSingleton(); + var services = serviceCollection.BuildServiceProvider(); var context = new HostingContext() { @@ -53,5 +54,13 @@ namespace MusicStore } return Task.FromResult(0); } + + private class TestHostingEnvironment : HostingEnvironment + { + public TestHostingEnvironment(IApplicationEnvironment env, IEnumerable configure) : base(env, configure) + { + WebRoot = "wwwroot"; + } + } } } \ No newline at end of file