Move Options to UseServices
Hosting default services wasn't working as expected, UseServices
This commit is contained in:
parent
8695da085b
commit
1189f10ba8
|
|
@ -59,14 +59,6 @@ namespace Microsoft.AspNet.Hosting
|
||||||
Lifecycle = LifecycleKind.Scoped
|
Lifecycle = LifecycleKind.Scoped
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Review whether this is the right long term home, and whether Scoped is correct lifetime
|
|
||||||
yield return new ServiceDescriptor
|
|
||||||
{
|
|
||||||
ServiceType = typeof(IOptionsAccessor<>),
|
|
||||||
ImplementationType = typeof(OptionsAccessor<>),
|
|
||||||
Lifecycle = LifecycleKind.Scoped
|
|
||||||
};
|
|
||||||
|
|
||||||
if (PlatformHelper.IsMono)
|
if (PlatformHelper.IsMono)
|
||||||
{
|
{
|
||||||
#if NET45
|
#if NET45
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,15 @@ namespace Microsoft.AspNet.Builder
|
||||||
public static IBuilder UseServices(this IBuilder builder, Action<ServiceCollection> configureServices)
|
public static IBuilder UseServices(this IBuilder builder, Action<ServiceCollection> configureServices)
|
||||||
{
|
{
|
||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = new ServiceCollection();
|
||||||
|
|
||||||
|
// TODO: Review whether this is the right long term home, and whether Scoped is correct lifetime
|
||||||
|
serviceCollection.Add(new ServiceDescriptor
|
||||||
|
{
|
||||||
|
ServiceType = typeof(IOptionsAccessor<>),
|
||||||
|
ImplementationType = typeof(OptionsAccessor<>),
|
||||||
|
Lifecycle = LifecycleKind.Scoped
|
||||||
|
});
|
||||||
|
|
||||||
configureServices(serviceCollection);
|
configureServices(serviceCollection);
|
||||||
builder.ApplicationServices = serviceCollection.BuildServiceProvider(builder.ApplicationServices);
|
builder.ApplicationServices = serviceCollection.BuildServiceProvider(builder.ApplicationServices);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue