Move IServiceCollection extension to Microsoft.Framework.DependencyInjection namespace
Fixes: https://github.com/aspnet/Diagnostics/issues/96
This commit is contained in:
parent
2337d7808d
commit
6ee155c40f
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using Jetbrains.Annotations;
|
using Jetbrains.Annotations;
|
||||||
using Microsoft.AspNet.Diagnostics.Elm;
|
using Microsoft.AspNet.Diagnostics.Elm;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
|
|
@ -33,14 +32,5 @@ namespace Microsoft.AspNet.Builder
|
||||||
{
|
{
|
||||||
return builder.UseMiddleware<ElmPageMiddleware>();
|
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 => { }));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue