Skip to content

Commit bc11715

Browse files
committed
Fix broken build
Returned accidentally removed StartupConfiguratiionExtensions file and removed what supposed to be removed ApplicationBuilderExtensions, plus resolved warning happened after merge of one of PRs
1 parent 3fe0c9c commit bc11715

File tree

3 files changed

+56
-41
lines changed

3 files changed

+56
-41
lines changed

Extensions/Xtensive.Orm.Web/ApplicationBuilderExtensions.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (C) 2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
6+
using Microsoft.AspNetCore.Builder;
7+
using Microsoft.Extensions.DependencyInjection;
8+
using Microsoft.AspNetCore.Mvc.Filters;
9+
using Xtensive.Orm.Web.Filters;
10+
using Xtensive.Orm.Web.Middleware;
11+
12+
namespace Xtensive.Orm.Web
13+
{
14+
/// <summary>
15+
/// Contains extensions which are used in Startup.cs to configure application
16+
/// </summary>
17+
public static class StartupConfigurationExtensions
18+
{
19+
/// <summary>
20+
/// Adds <see cref="OpenSessionMiddleware"/> to ASP.NET Core middleware pipeline.
21+
/// </summary>
22+
/// <param name="builder"><see cref="IApplicationBuilder"/> instance.</param>
23+
/// <returns><paramref name="builder"/> with <see cref="OpenSessionMiddleware"/>.</returns>
24+
public static IApplicationBuilder UseDataObjectsSessionOpener(this IApplicationBuilder builder) =>
25+
builder.UseMiddleware<OpenSessionMiddleware>();
26+
27+
/// <summary>
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.
31+
/// </summary>
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);
53+
}
54+
}

Orm/Xtensive.Orm.Tests/Storage/SessionEventsTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public class EventInfo : SessionBound, IDisposable
5656
public EntityFieldValueEventArgs EntityFieldValueSettingArgs;
5757
public EntityFieldValueSetEventArgs EntityFieldValueSetArgs;
5858

59-
public QueryEventArgs? QueryExecuting;
60-
public QueryEventArgs? QueryExecuted;
59+
public QueryEventArgs QueryExecuting;
60+
public QueryEventArgs QueryExecuted;
6161

6262
public DbCommandEventArgs? DbCommandExecuting;
6363
public DbCommandEventArgs? DbCommandExecuted;

0 commit comments

Comments
 (0)