Move Options to UseServices

Hosting default services wasn't working as expected,
UseServices
This commit is contained in:
Hao Kung 2014-05-15 18:11:51 -07:00
parent 8695da085b
commit 1189f10ba8
2 changed files with 9 additions and 8 deletions

View File

@ -59,14 +59,6 @@ namespace Microsoft.AspNet.Hosting
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 NET45

View File

@ -64,6 +64,15 @@ namespace Microsoft.AspNet.Builder
public static IBuilder UseServices(this IBuilder builder, Action<ServiceCollection> configureServices)
{
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);
builder.ApplicationServices = serviceCollection.BuildServiceProvider(builder.ApplicationServices);