public SessionMiddleware( [NotNull] RequestDelegate next, [NotNull] ILoggerFactory loggerFactory, [NotNull] IEnumerable<ISessionStore> sessionStore, [NotNull] IOptions<SessionOptions> options, [NotNull] ConfigureOptions<SessionOptions> configureOptions) { _next = next; _logger = loggerFactory.Create<SessionMiddleware>(); if (configureOptions != null) { _options = options.GetNamedOptions(configureOptions.Name); configureOptions.Configure(_options); } else { _options = options.Options; } if (_options.Store == null) { _options.Store = sessionStore.FirstOrDefault(); if (_options.Store == null) { throw new ArgumentException("ISessionStore must be specified."); } } _options.Store.Connect(); }
/// <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( RequestDelegate next, ILoggerFactory loggerFactory, ISessionStore sessionStore, IOptions<SessionOptions> options) { if (next == null) { throw new ArgumentNullException(nameof(next)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } if (sessionStore == null) { throw new ArgumentNullException(nameof(sessionStore)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _next = next; _logger = loggerFactory.CreateLogger<SessionMiddleware>(); _options = options.Value; _sessionStore = sessionStore; _sessionStore.Connect(); }
/// <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, [NotNull] ISessionStore sessionStore, [NotNull] IOptions<SessionOptions> options) { _next = next; _logger = loggerFactory.CreateLogger<SessionMiddleware>(); _options = options.Options; _sessionStore = sessionStore; _sessionStore.Connect(); }
public SessionEstablisher(HttpContext context, string sessionKey, SessionOptions options) { _context = context; _sessionKey = sessionKey; _options = options; context.Response.OnSendingHeaders(OnSendingHeadersCallback, state: this); }