Move IServiceCollection extension to Microsoft.Framework.DependencyInjection namespace

Fixes: https://github.com/aspnet/Diagnostics/issues/96
This commit is contained in:
Praburaj 2015-03-12 12:13:56 -07:00
parent 2337d7808d
commit 6ee155c40f
3 changed files with 39 additions and 11 deletions

View File

@ -1,7 +1,6 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Jetbrains.Annotations;
using Microsoft.AspNet.Diagnostics.Elm;
using Microsoft.Framework.DependencyInjection;
@ -33,14 +32,5 @@ namespace Microsoft.AspNet.Builder
{
return builder.UseMiddleware<ElmPageMiddleware>();
}
/// <summary>
/// Registers an <see cref="ElmStore"/> and configures <see cref="ElmOptions"/>.
/// </summary>
public static IServiceCollection AddElm([NotNull] this IServiceCollection services, Action<ElmOptions> configureOptions = null)
{
services.AddSingleton<ElmStore>(); // registering the service so it can be injected into constructors
return services.Configure(configureOptions ?? (o => { }));
}
}
}

View File

@ -0,0 +1,35 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Jetbrains.Annotations;
using Microsoft.AspNet.Diagnostics.Elm;
namespace Microsoft.Framework.DependencyInjection
{
public static class ElmServiceCollectionExtensions
{
/// <summary>
/// Registers an <see cref="ElmStore"/> and configures <see cref="ElmOptions"/>.
/// </summary>
public static IServiceCollection AddElm([NotNull] this IServiceCollection services)
{
return services.AddElm(configureOptions: null);
}
/// <summary>
/// Registers an <see cref="ElmStore"/> and configures <see cref="ElmOptions"/>.
/// </summary>
public static IServiceCollection AddElm([NotNull] this IServiceCollection services, Action<ElmOptions> configureOptions)
{
services.AddSingleton<ElmStore>(); // registering the service so it can be injected into constructors
if (configureOptions != null)
{
services.Configure(configureOptions);
}
return services;
}
}
}

View File

@ -1,4 +1,7 @@
using System;
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;