Move IServiceCollection extensions into Microsoft.Framework.DependencyInjection namespace

Fixes:
https://github.com/aspnet/Session/issues/10
https://github.com/aspnet/Session/issues/8

1. Renaming the class name containing the extension
2. Consolidating the AddSession() and ConfigureSession overloads with same pattern we follow in other repos
3. Rename AddSessionServices() => AddSession() like all other repos
This commit is contained in:
Praburaj 2015-03-12 13:21:02 -07:00
parent c2cbd62eec
commit 6c57ca7c1e
4 changed files with 30 additions and 23 deletions

View File

@ -3,7 +3,6 @@ using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
using Microsoft.Framework.Logging.Console;
namespace SessionSample
{
@ -17,7 +16,7 @@ namespace SessionSample
public void ConfigureServices(IServiceCollection services)
{
services.AddCaching();
services.AddSessionServices();
services.AddSession();
}
public void Configure(IApplicationBuilder app)
@ -58,4 +57,4 @@ namespace SessionSample
});
}
}
}
}

View File

@ -1,15 +0,0 @@
// 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 Microsoft.AspNet.Session;
namespace Microsoft.Framework.DependencyInjection
{
public static class CachingServicesExtensions
{
public static IServiceCollection AddSessionServices(this IServiceCollection collection)
{
return collection.AddTransient<ISessionStore, DistributedSessionStore>();
}
}
}

View File

@ -13,11 +13,6 @@ namespace Microsoft.AspNet.Builder
{
public static class SessionMiddlewareExtensions
{
public static IServiceCollection ConfigureSession([NotNull] this IServiceCollection services, [NotNull] Action<SessionOptions> configure)
{
return services.ConfigureOptions(configure);
}
public static IApplicationBuilder UseInMemorySession([NotNull] this IApplicationBuilder app, IMemoryCache cache = null, Action<SessionOptions> configure = null)
{
return app.UseDistributedSession(new LocalCache(cache ?? new MemoryCache(new MemoryCacheOptions())), configure);

View File

@ -0,0 +1,28 @@
// 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 Microsoft.AspNet.Session;
namespace Microsoft.Framework.DependencyInjection
{
public static class SessionServiceCollectionExtensions
{
public static IServiceCollection AddSession([NotNull] this IServiceCollection services)
{
return services.AddSession(configure: null);
}
public static IServiceCollection AddSession([NotNull] this IServiceCollection services, Action<SessionOptions> configure)
{
services.AddTransient<ISessionStore, DistributedSessionStore>();
if (configure != null)
{
services.Configure(configure);
}
return services;
}
}
}