Skip to content

Commit

Permalink
using UseServerExecutionContextMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidEggenberger committed Mar 7, 2024
1 parent 263da4b commit 6e53253
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Source/Shared/Features/EFCore/Registrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Shared.Features.EFCore.Configuration;
using Shared.Features.Server.ExecutionContext;

namespace Shared.Features.EFCore
{
Expand All @@ -20,7 +19,7 @@ public static IServiceCollection RegisterEFCore(this IServiceCollection services

public static IApplicationBuilder UseEFCoreMiddleware(this IApplicationBuilder app)
{
app.UseMiddleware<ServerExecutionContextMiddleware>();
app.UseMiddleware<TransactionScopeMiddleware>();

return app;
}
Expand Down
4 changes: 4 additions & 0 deletions Source/Shared/Features/Registrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Shared.Features.EFCore;
using Shared.Features.EmailSender;
using Shared.Features.Modules;
using Shared.Features.Server.ExecutionContext;

namespace Shared.Features
{
Expand All @@ -20,12 +21,15 @@ public static IServiceCollection AddSharedFeatures(this IServiceCollection servi
services.RegisterEFCore(configuration);
services.RegisterEmailSender(configuration);

services.AddServerExecutionContext();

return services;
}

public static IApplicationBuilder UseSharedFeaturesMiddleware(this IApplicationBuilder app)
{
app.UseEFCoreMiddleware();
app.UseServerExecutionContextMiddleware();

return app;
}
Expand Down
10 changes: 9 additions & 1 deletion Source/Shared/Features/Server/ExecutionContext/Registrator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Shared.Kernel.BuildingBlocks;

namespace Shared.Features.Server.ExecutionContext
Expand All @@ -12,5 +13,12 @@ public static IServiceCollection AddServerExecutionContext(this IServiceCollecti
services.AddScoped<IExecutionContext, ServerExecutionContext>(ServerExecutionContext.CreateInstance);
return services;
}

public static IApplicationBuilder UseServerExecutionContextMiddleware(this IApplicationBuilder app)
{
app.UseMiddleware<ServerExecutionContextMiddleware>();

return app;
}
}
}
3 changes: 1 addition & 2 deletions Source/Web/Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public void ConfigureServices(IServiceCollection services)

services.AddAuth();

services.AddServerExecutionContext();
services.AddBuildingBlocks();
services.AddSharedFeatures();

Expand Down Expand Up @@ -67,8 +66,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseAuthentication();
app.UseAuthorization();

app.UseSharedFeaturesMiddleware();
app.UseBuildingBlocksMiddleware();
app.UseSharedFeaturesMiddleware();

app.UseModules(env);

Expand Down

0 comments on commit 6e53253

Please sign in to comment.