React to hosting changes
This commit is contained in:
parent
5ae536fe0a
commit
4267d9b25f
|
|
@ -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;
|
||||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||||
using Microsoft.AspNet.Hosting;
|
using Microsoft.Framework.Runtime;
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MusicStore
|
namespace MusicStore
|
||||||
{
|
{
|
||||||
|
|
@ -26,10 +28,9 @@ namespace MusicStore
|
||||||
var config = new Configuration();
|
var config = new Configuration();
|
||||||
config.AddCommandLine(args);
|
config.AddCommandLine(args);
|
||||||
|
|
||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = HostingServices.Create(_hostServiceProvider);
|
||||||
serviceCollection.Add(HostingServices.GetDefaultServices(config));
|
serviceCollection.AddSingleton<IHostingEnvironment, TestHostingEnvironment>();
|
||||||
serviceCollection.AddInstance<IHostingEnvironment>(new HostingEnvironment() { WebRoot = "wwwroot" });
|
var services = serviceCollection.BuildServiceProvider();
|
||||||
var services = serviceCollection.BuildServiceProvider(_hostServiceProvider);
|
|
||||||
|
|
||||||
var context = new HostingContext()
|
var context = new HostingContext()
|
||||||
{
|
{
|
||||||
|
|
@ -53,5 +54,13 @@ namespace MusicStore
|
||||||
}
|
}
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestHostingEnvironment : HostingEnvironment
|
||||||
|
{
|
||||||
|
public TestHostingEnvironment(IApplicationEnvironment env, IEnumerable<IConfigureHostingEnvironment> configure) : base(env, configure)
|
||||||
|
{
|
||||||
|
WebRoot = "wwwroot";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue