Merge pull request #43 from hishamco/docs

SessionServiceCollection & SessionMiddleware docs
This commit is contained in:
Eilon Lipton 2015-06-27 12:04:02 -07:00
commit 13ff3159ea
3 changed files with 36 additions and 0 deletions

View File

@ -15,6 +15,9 @@ using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Session
{
/// <summary>
/// Enables the session state for the application.
/// </summary>
public class SessionMiddleware
{
private static readonly RandomNumberGenerator CryptoRandom = RandomNumberGenerator.Create();
@ -25,6 +28,13 @@ namespace Microsoft.AspNet.Session
private readonly ILogger _logger;
private readonly ISessionStore _sessionStore;
/// <summary>
/// Creates a new <see cref="SessionMiddleware"/>.
/// </summary>
/// <param name="next">The <see cref="RequestDelegate"/> representing the next middleware in the pipeline.</param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> representing the factory that used to create logger instances.</param>
/// <param name="sessionStore">The <see cref="ISessionStore"/> representing the session store.</param>
/// <param name="options">The session configuration options.</param>
public SessionMiddleware(
[NotNull] RequestDelegate next,
[NotNull] ILoggerFactory loggerFactory,
@ -38,6 +48,11 @@ namespace Microsoft.AspNet.Session
_sessionStore.Connect();
}
/// <summary>
/// Invokes the logic of the middleware.
/// </summary>
/// <param name="context">The <see cref="HttpContext"/>.</param>
/// <returns>A <see cref="Task"/> that completes when the middleware has completed processing.</returns>
public async Task Invoke(HttpContext context)
{
var isNewSessionKey = false;

View File

@ -6,8 +6,16 @@ using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Builder
{
/// <summary>
/// Extension methods for adding the <see cref="SessionMiddleware"/> to an application.
/// </summary>
public static class SessionMiddlewareExtensions
{
/// <summary>
/// Adds the <see cref="SessionMiddleware"/> to automatically enable session state for the application.
/// </summary>
/// <param name="app">The <see cref="IApplicationBuilder"/>.</param>
/// <returns>The <see cref="IApplicationBuilder"/>.</returns>
public static IApplicationBuilder UseSession([NotNull] this IApplicationBuilder app)
{
return app.UseMiddleware<SessionMiddleware>();

View File

@ -7,8 +7,16 @@ using Microsoft.Framework.Internal;
namespace Microsoft.Framework.DependencyInjection
{
/// <summary>
/// Extension methods for adding session services to the DI container.
/// </summary>
public static class SessionServiceCollectionExtensions
{
/// <summary>
/// Adds services required for application session state.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
/// <returns>The <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddSession([NotNull] this IServiceCollection services)
{
services.AddOptions();
@ -16,6 +24,11 @@ namespace Microsoft.Framework.DependencyInjection
return services;
}
/// <summary>
/// Configures the session.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> to configure the services.</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)