22// This code is distributed under MIT license terms.
33// See the License.txt file in the project root for more information.
44
5+ using System ;
56using Microsoft . AspNetCore . Builder ;
67using Microsoft . Extensions . DependencyInjection ;
8+ using Microsoft . AspNetCore . Mvc . Filters ;
9+ using Xtensive . Orm . Web . Filters ;
10+ using Xtensive . Orm . Web . Middleware ;
711
812namespace Xtensive . Orm . Web
913{
@@ -13,23 +17,38 @@ namespace Xtensive.Orm.Web
1317 public static class StartupConfigurationExtensions
1418 {
1519 /// <summary>
16- /// Adds <see cref="SessionManager "/> to ASP.NET Core middleware pipeline.
20+ /// Adds <see cref="OpenSessionMiddleware "/> to ASP.NET Core middleware pipeline.
1721 /// </summary>
1822 /// <param name="builder"><see cref="IApplicationBuilder"/> instance.</param>
19- /// <returns><paramref name="builder"/> with <see cref="SessionManager"/>.</returns>
20- public static IApplicationBuilder UseDataObjectsSessionsOpener ( this IApplicationBuilder builder )
21- {
22- return builder . UseMiddleware < OpenSessionMiddlewere > ( ) ;
23- }
23+ /// <returns><paramref name="builder"/> with <see cref="OpenSessionMiddleware"/>.</returns>
24+ public static IApplicationBuilder UseDataObjectsSessionOpener ( this IApplicationBuilder builder ) =>
25+ builder . UseMiddleware < OpenSessionMiddleware > ( ) ;
2426
2527 /// <summary>
26- /// Registers a SessionAccessor as scoped service for futher usage with
28+ /// Registers a <see cref="SessionAccessor"/> as scoped service to be able to
29+ /// have access to session/transaction as parameter in either MVC controllers' actions or
30+ /// constuctors, and in Razor Pages.
2731 /// </summary>
28- /// <param name="services"></param>
29- /// <returns>The same instance collection with service.</returns>
30- public static IServiceCollection AddSessionAccessor ( this IServiceCollection services )
31- {
32- return services . AddScoped < SessionAccessor > ( ) ;
33- }
32+ /// <param name="services">A service collection to add <see cref="SessionAccessor"/>.</param>
33+ /// <returns>The same collection instance with registered accessor.</returns>
34+ public static IServiceCollection AddDataObjectsSessionAccessor ( this IServiceCollection services ) =>
35+ services . AddScoped < SessionAccessor > ( ) ;
36+
37+ /// <summary>
38+ /// Adds <see cref="SessionActionFilter"/> to action filters.
39+ /// </summary>
40+ /// <param name="filters">The filter collection to add the filter.</param>
41+ /// <returns>A <see cref="IFilterMetadata"/> representing added filter.</returns>
42+ public static IFilterMetadata AddDataObjectsSessionActionFilter ( this FilterCollection filters ) =>
43+ AddDataObjectsSessionActionFilter ( filters , 0 ) ;
44+
45+ /// <summary>
46+ /// Adds <see cref="SessionActionFilter"/> to action filters.
47+ /// </summary>
48+ /// <param name="filters">The filter collection to add the filter.</param>
49+ /// <param name="order">The order of the added filter.</param>
50+ /// <returns>A <see cref="IFilterMetadata"/> representing added filter.</returns>
51+ public static IFilterMetadata AddDataObjectsSessionActionFilter ( this FilterCollection filters , int order ) =>
52+ filters . Add ( typeof ( SessionActionFilter ) , order ) ;
3453 }
35- }
54+ }
0 commit comments