Skip to content

Commit 4b5d07b

Browse files
committed
Fix Mediator registration
1 parent 85f1c0a commit 4b5d07b

File tree

2 files changed

+49
-48
lines changed

2 files changed

+49
-48
lines changed
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
using KSFramework.Messaging.Abstraction;
2-
using Microsoft.Extensions.DependencyInjection;
3-
using System.Reflection;
4-
5-
namespace KSFramework.Messaging.Configuration
6-
{
7-
/// <summary>
8-
/// Extension methods to register messaging components into the service collection.
9-
/// </summary>
10-
public static class ServiceCollectionExtensions
11-
{
12-
/// <summary>
13-
/// Registers mediator handlers and behaviors from specified assemblies with automatic discovery.
14-
/// </summary>
15-
public static IServiceCollection AddKSMediator(this IServiceCollection services, params Assembly[] assemblies)
16-
{
17-
services.AddScoped<IMediator, Mediator>();
18-
services.AddScoped<ISender>(sp => sp.GetRequiredService<IMediator>());
19-
20-
services.Scan(scan => scan
21-
.FromAssemblies(assemblies)
22-
23-
// Request Handlers
24-
.AddClasses(c => c.AssignableTo(typeof(IRequestHandler<,>)))
25-
.AsImplementedInterfaces()
26-
.WithScopedLifetime()
27-
28-
// Notification Handlers
29-
.AddClasses(c => c.AssignableTo(typeof(INotificationHandler<>)))
30-
.AsImplementedInterfaces()
31-
.WithScopedLifetime()
32-
33-
// Pipeline Behaviors
34-
.AddClasses(c => c.AssignableTo(typeof(IPipelineBehavior<,>)))
35-
.AsImplementedInterfaces()
36-
.WithScopedLifetime()
37-
38-
// Notification Behaviors
39-
.AddClasses(c => c.AssignableTo(typeof(INotificationBehavior<>)))
40-
.AsImplementedInterfaces()
41-
.WithScopedLifetime()
42-
);
43-
44-
return services;
45-
}
46-
}
47-
}
1+
// using KSFramework.Messaging.Abstraction;
2+
// using Microsoft.Extensions.DependencyInjection;
3+
// using System.Reflection;
4+
//
5+
// namespace KSFramework.Messaging.Configuration
6+
// {
7+
// /// <summary>
8+
// /// Extension methods to register messaging components into the service collection.
9+
// /// </summary>
10+
// public static class ServiceCollectionExtensions
11+
// {
12+
// /// <summary>
13+
// /// Registers mediator handlers and behaviors from specified assemblies with automatic discovery.
14+
// /// </summary>
15+
// public static IServiceCollection AddKSMediator(this IServiceCollection services, params Assembly[] assemblies)
16+
// {
17+
// services.AddScoped<IMediator, Mediator>();
18+
// services.AddScoped<ISender>(sp => sp.GetRequiredService<IMediator>());
19+
//
20+
// services.Scan(scan => scan
21+
// .FromAssemblies(assemblies)
22+
//
23+
// // Request Handlers
24+
// .AddClasses(c => c.AssignableTo(typeof(IRequestHandler<,>)))
25+
// .AsImplementedInterfaces()
26+
// .WithScopedLifetime()
27+
//
28+
// // Notification Handlers
29+
// .AddClasses(c => c.AssignableTo(typeof(INotificationHandler<>)))
30+
// .AsImplementedInterfaces()
31+
// .WithScopedLifetime()
32+
//
33+
// // Pipeline Behaviors
34+
// .AddClasses(c => c.AssignableTo(typeof(IPipelineBehavior<,>)))
35+
// .AsImplementedInterfaces()
36+
// .WithScopedLifetime()
37+
//
38+
// // Notification Behaviors
39+
// .AddClasses(c => c.AssignableTo(typeof(INotificationBehavior<>)))
40+
// .AsImplementedInterfaces()
41+
// .WithScopedLifetime()
42+
// );
43+
//
44+
// return services;
45+
// }
46+
// }
47+
// }

src/KSFramework/Messaging/Extensions/RegisterMediatorServices.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public static class RegisterMediatorServices
1818
/// <returns>The service collection.</returns>
1919
public static IServiceCollection AddKSMediator(this IServiceCollection services, params Assembly[] assemblies)
2020
{
21-
services.AddSingleton<IMediator, Mediator>();
21+
services.AddScoped<IMediator, Mediator>();
22+
services.AddScoped<ISender>(sp => sp.GetRequiredService<IMediator>());
2223

2324
services.Scan(scan => scan
2425
.FromAssemblies(assemblies)

0 commit comments

Comments
 (0)