Skip to content

Commit 22974bb

Browse files
committed
refactor: move AddDaprEventBus to a separate class
1 parent 7b4badc commit 22974bb

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

src/Cnblogs.Architecture.Ddd.Cqrs.DependencyInjection.EventBus.Dapr/CqrsInjectorExtensions.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using System.Reflection;
2-
32
using Cnblogs.Architecture.Ddd.EventBus.Abstractions;
4-
using Cnblogs.Architecture.Ddd.EventBus.Dapr;
5-
63
using Microsoft.Extensions.DependencyInjection;
74

85
namespace Cnblogs.Architecture.Ddd.Cqrs.DependencyInjection.EventBus.Dapr;
@@ -41,18 +38,4 @@ public static CqrsInjector AddDaprEventBus(this CqrsInjector cqrsInjector, strin
4138
cqrsInjector.Services.AddDaprEventBus(appName);
4239
return cqrsInjector;
4340
}
44-
45-
/// <summary>
46-
/// Register <see cref="DaprClient"/> and <see cref="IEventBus"/>.
47-
/// </summary>
48-
/// <param name="services"><see cref="IServiceCollection"/></param>
49-
/// <param name="appName">The app name used when publishing integration events.</param>
50-
/// <returns></returns>
51-
public static IServiceCollection AddDaprEventBus(this IServiceCollection services, string appName)
52-
{
53-
services.Configure<DaprOptions>(o => o.AppName = appName);
54-
services.AddControllers().AddDapr();
55-
services.AddScoped<IEventBus, DaprEventBus>();
56-
return services;
57-
}
5841
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Cnblogs.Architecture.Ddd.EventBus.Abstractions;
2+
using Cnblogs.Architecture.Ddd.EventBus.Dapr;
3+
using Dapr.Client;
4+
5+
namespace Microsoft.Extensions.DependencyInjection;
6+
7+
/// <summary>
8+
/// IServiceCollection extensions for DaprEventBus
9+
/// </summary>
10+
public static class DaprEventBusServiceCollectionExtensions
11+
{
12+
/// <summary>
13+
/// Register <see cref="DaprClient"/> and <see cref="IEventBus"/>.
14+
/// </summary>
15+
/// <param name="services"><see cref="IServiceCollection"/></param>
16+
/// <param name="appName">The app name used when publishing integration events.</param>
17+
/// <returns></returns>
18+
public static IServiceCollection AddDaprEventBus(this IServiceCollection services, string appName)
19+
{
20+
services.Configure<DaprOptions>(o => o.AppName = appName);
21+
services.AddControllers().AddDapr();
22+
services.AddScoped<IEventBus, DaprEventBus>();
23+
return services;
24+
}
25+
}

0 commit comments

Comments
 (0)