Updating to new options pattern
This commit is contained in:
parent
e91ce99c70
commit
c59528e4f9
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Session;
|
using Microsoft.AspNet.Session;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Builder
|
namespace Microsoft.AspNet.Builder
|
||||||
{
|
{
|
||||||
|
|
@ -25,5 +26,25 @@ namespace Microsoft.AspNet.Builder
|
||||||
|
|
||||||
return app.UseMiddleware<SessionMiddleware>();
|
return app.UseMiddleware<SessionMiddleware>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the <see cref="SessionMiddleware"/> to automatically enable session state for the application.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="app">The <see cref="IApplicationBuilder"/>.</param>
|
||||||
|
/// <param name="options">The <see cref="SessionOptions"/>.</param>
|
||||||
|
/// <returns>The <see cref="IApplicationBuilder"/>.</returns>
|
||||||
|
public static IApplicationBuilder UseSession(this IApplicationBuilder app, SessionOptions options)
|
||||||
|
{
|
||||||
|
if (app == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(app));
|
||||||
|
}
|
||||||
|
if (options == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
return app.UseMiddleware<SessionMiddleware>(Options.Create(options));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,8 +2,9 @@
|
||||||
// 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 System;
|
||||||
|
using Microsoft.AspNet.Session;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Session
|
namespace Microsoft.AspNet.Builder
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the session state options for the application.
|
/// Represents the session state options for the application.
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// 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 System;
|
||||||
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Session;
|
using Microsoft.AspNet.Session;
|
||||||
|
|
||||||
namespace Microsoft.Extensions.DependencyInjection
|
namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
@ -22,8 +23,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(services));
|
throw new ArgumentNullException(nameof(services));
|
||||||
}
|
}
|
||||||
|
|
||||||
services.AddOptions();
|
|
||||||
services.AddTransient<ISessionStore, DistributedSessionStore>();
|
services.AddTransient<ISessionStore, DistributedSessionStore>();
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue