ConfigureSession => AddSession overload

This commit is contained in:
Hao Kung 2015-09-11 14:16:13 -07:00
parent dfaf6bb2ff
commit 2bd83e1589
3 changed files with 8 additions and 12 deletions

View File

@ -36,9 +36,7 @@ namespace SessionSample
// Adds a default in-memory implementation of IDistributedCache
services.AddCaching();
services.AddSession();
services.ConfigureSession(o =>
services.AddSession(o =>
{
o.IdleTimeout = TimeSpan.FromSeconds(10);
});

View File

@ -25,15 +25,15 @@ namespace Microsoft.Framework.DependencyInjection
}
/// <summary>
/// Configures the session.
/// Adds services required for application session state.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> to configure the services.</param>
/// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
/// <param name="configure">The session options to configure the middleware with.</param>
public static void ConfigureSession(
[NotNull] this IServiceCollection services,
[NotNull] Action<SessionOptions> configure)
/// <returns>The <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddSession([NotNull] this IServiceCollection services, Action<SessionOptions> configure)
{
services.Configure(configure);
return services.AddSession();
}
}
}

View File

@ -275,8 +275,7 @@ namespace Microsoft.AspNet.Session
{
services.AddInstance(typeof(ILoggerFactory), loggerFactory);
services.AddCaching();
services.AddSession();
services.ConfigureSession(o => o.IdleTimeout = TimeSpan.FromMilliseconds(30));
services.AddSession(o => o.IdleTimeout = TimeSpan.FromMilliseconds(30));
}))
{
var client = server.CreateClient();
@ -328,8 +327,7 @@ namespace Microsoft.AspNet.Session
{
services.AddInstance(typeof(ILoggerFactory), new NullLoggerFactory());
services.AddCaching();
services.AddSession();
services.ConfigureSession(o => o.IdleTimeout = TimeSpan.FromMinutes(20));
services.AddSession(o => o.IdleTimeout = TimeSpan.FromMinutes(20));
services.Configure<MemoryCacheOptions>(o => o.Clock = clock);
}))
{