React to hosting changes

This commit is contained in:
Hao Kung 2014-11-20 18:13:03 -08:00
parent 5ae536fe0a
commit 4267d9b25f
1 changed files with 17 additions and 8 deletions

View File

@ -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<IHostingEnvironment>(new HostingEnvironment() { WebRoot = "wwwroot" });
var services = serviceCollection.BuildServiceProvider(_hostServiceProvider);
var serviceCollection = HostingServices.Create(_hostServiceProvider);
serviceCollection.AddSingleton<IHostingEnvironment, TestHostingEnvironment>();
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<IConfigureHostingEnvironment> configure) : base(env, configure)
{
WebRoot = "wwwroot";
}
}
}
}