From 6ee155c40fa052e0ce349871166469f51a254b70 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Thu, 12 Mar 2015 12:13:56 -0700 Subject: [PATCH] Move IServiceCollection extension to Microsoft.Framework.DependencyInjection namespace Fixes: https://github.com/aspnet/Diagnostics/issues/96 --- .../ElmExtensions.cs | 10 ------ .../ElmServiceCollectionExtensions.cs | 35 +++++++++++++++++++ .../ElmLoggerTest.cs | 5 ++- 3 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 src/Microsoft.AspNet.Diagnostics.Elm/ElmServiceCollectionExtensions.cs diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/ElmExtensions.cs b/src/Microsoft.AspNet.Diagnostics.Elm/ElmExtensions.cs index 29811f5f84..5c88ebe038 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/ElmExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics.Elm/ElmExtensions.cs @@ -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(); } - - /// - /// Registers an and configures . - /// - public static IServiceCollection AddElm([NotNull] this IServiceCollection services, Action configureOptions = null) - { - services.AddSingleton(); // registering the service so it can be injected into constructors - return services.Configure(configureOptions ?? (o => { })); - } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/ElmServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Diagnostics.Elm/ElmServiceCollectionExtensions.cs new file mode 100644 index 0000000000..eb35d52937 --- /dev/null +++ b/src/Microsoft.AspNet.Diagnostics.Elm/ElmServiceCollectionExtensions.cs @@ -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 + { + /// + /// Registers an and configures . + /// + public static IServiceCollection AddElm([NotNull] this IServiceCollection services) + { + return services.AddElm(configureOptions: null); + } + + /// + /// Registers an and configures . + /// + public static IServiceCollection AddElm([NotNull] this IServiceCollection services, Action configureOptions) + { + services.AddSingleton(); // registering the service so it can be injected into constructors + + if (configureOptions != null) + { + services.Configure(configureOptions); + } + + return services; + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Diagnostics.Tests/ElmLoggerTest.cs b/test/Microsoft.AspNet.Diagnostics.Tests/ElmLoggerTest.cs index 597b740a96..e17acb48b5 100644 --- a/test/Microsoft.AspNet.Diagnostics.Tests/ElmLoggerTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Tests/ElmLoggerTest.cs @@ -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;