Skip to content

Commit dbccf48

Browse files
committed
Renamed extension method to RegisterCommandHandlersByAttribute
1 parent 3129d7e commit dbccf48

File tree

2 files changed

+25
-40
lines changed

2 files changed

+25
-40
lines changed

Src/Xer.Cqrs.CommandStack.Extensions.Attributes/SingleMessageHandlerRegistrationExtensions.cs

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public static partial class SingleMessageHandlerRegistrationExtensions
3333
/// </remarks>
3434
/// <param name="registration">Message handler registration.</param>
3535
/// <param name="attributedObjectFactory">Factory delegate which provides an instance of a class that contains methods marked with [CommandHandler] attribute.</param>
36-
public static void RegisterCommandHandlerAttributes<TAttributed>(this SingleMessageHandlerRegistration registration,
37-
Func<TAttributed> attributedObjectFactory)
38-
where TAttributed : class
36+
public static void RegisterCommandHandlersByAttribute<TAttributed>(this SingleMessageHandlerRegistration registration,
37+
Func<TAttributed> attributedObjectFactory)
38+
where TAttributed : class
3939
{
40-
RegisterCommandHandlerAttributes(registration, CommandHandlerAttributeMethod.FromType<TAttributed>(attributedObjectFactory));
40+
RegisterCommandHandlersByAttribute(registration, CommandHandlerAttributeMethod.FromType<TAttributed>(attributedObjectFactory));
4141
}
4242

4343
/// <summary>
@@ -50,11 +50,11 @@ public static void RegisterCommandHandlerAttributes<TAttributed>(this SingleMess
5050
/// <param name="registration">Message handler registration.</param>
5151
/// <param name="type">Type to scan for methods marked with the [CommandHandler] attribute.</param>
5252
/// <param name="instanceFactory">Factory delegate that provides an instance of the specified type.</param>
53-
public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerRegistration registration,
54-
Type type,
55-
Func<object> instanceFactory)
53+
public static void RegisterCommandHandlersByAttribute(this SingleMessageHandlerRegistration registration,
54+
Type type,
55+
Func<object> instanceFactory)
5656
{
57-
RegisterCommandHandlerAttributes(registration, CommandHandlerAttributeMethod.FromType(type, instanceFactory));
57+
RegisterCommandHandlersByAttribute(registration, CommandHandlerAttributeMethod.FromType(type, instanceFactory));
5858
}
5959

6060
/// <summary>
@@ -67,11 +67,11 @@ public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerReg
6767
/// <param name="registration">Message handler registration.</param>
6868
/// <param name="types">Types to scan for methods marked with the [CommandHandler] attribute.</param>
6969
/// <param name="instanceFactory">Factory delegate that provides an instance of a given type.</param>
70-
public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerRegistration registration,
71-
IEnumerable<Type> types,
72-
Func<Type, object> instanceFactory)
70+
public static void RegisterCommandHandlersByAttribute(this SingleMessageHandlerRegistration registration,
71+
IEnumerable<Type> types,
72+
Func<Type, object> instanceFactory)
7373
{
74-
RegisterCommandHandlerAttributes(registration, CommandHandlerAttributeMethod.FromTypes(types, instanceFactory));
74+
RegisterCommandHandlersByAttribute(registration, CommandHandlerAttributeMethod.FromTypes(types, instanceFactory));
7575
}
7676

7777
/// <summary>
@@ -84,11 +84,11 @@ public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerReg
8484
/// <param name="registration">Message handler registration.</param>
8585
/// <param name="assembly">Assembly to scan for methods marked with the [CommandHandler] attribute.</param>
8686
/// <param name="instanceFactory">Factory delegate that provides an instance of a type that has methods marked with [CommandHandler] attribute.</param>
87-
public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerRegistration registration,
88-
Assembly assembly,
89-
Func<Type, object> instanceFactory)
87+
public static void RegisterCommandHandlersByAttribute(this SingleMessageHandlerRegistration registration,
88+
Assembly assembly,
89+
Func<Type, object> instanceFactory)
9090
{
91-
RegisterCommandHandlerAttributes(registration, CommandHandlerAttributeMethod.FromAssembly(assembly, instanceFactory));
91+
RegisterCommandHandlersByAttribute(registration, CommandHandlerAttributeMethod.FromAssembly(assembly, instanceFactory));
9292
}
9393

9494
/// <summary>
@@ -101,26 +101,11 @@ public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerReg
101101
/// <param name="registration">Message handler registration.</param>
102102
/// <param name="assembly">Assembly to scan for methods marked with the [CommandHandler] attribute.</param>
103103
/// <param name="instanceFactory">Factory delegate that provides an instance of a type that has methods marked with [CommandHandler] attribute.</param>
104-
public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerRegistration registration,
105-
IEnumerable<Assembly> assemblies,
106-
Func<Type, object> instanceFactory)
104+
public static void RegisterCommandHandlersByAttribute(this SingleMessageHandlerRegistration registration,
105+
IEnumerable<Assembly> assemblies,
106+
Func<Type, object> instanceFactory)
107107
{
108-
RegisterCommandHandlerAttributes(registration, CommandHandlerAttributeMethod.FromAssemblies(assemblies, instanceFactory));
109-
}
110-
111-
/// <summary>
112-
/// Register methods marked with the [CommandHandler] attribute as command handlers.
113-
/// <para>Supported signatures for methods marked with [CommandHandler] are: (Methods can be named differently)</para>
114-
/// <para>void HandleCommand(TCommand command);</para>
115-
/// <para>Task HandleCommandAsync(TCommand command);</para>
116-
/// <para>Task HandleCommandAsync(TCommand command, CancellationToken cancellationToken);</para>
117-
/// </summary>
118-
/// <param name="registration">Message handler registration.</param>
119-
/// <param name="commandHandlerMethod">Object which represents a method marked with [CommandHandler] attribute.</param>
120-
public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerRegistration registration,
121-
CommandHandlerAttributeMethod commandHandlerMethod)
122-
{
123-
RegisterCommandHandlerAttributes(registration, new[] { commandHandlerMethod });
108+
RegisterCommandHandlersByAttribute(registration, CommandHandlerAttributeMethod.FromAssemblies(assemblies, instanceFactory));
124109
}
125110

126111
/// <summary>
@@ -132,8 +117,8 @@ public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerReg
132117
/// </summary>
133118
/// <param name="registration">Message handler registration.</param>
134119
/// <param name="commandHandlerMethods">Objects which represent methods marked with [CommandHandler] attribute.</param>
135-
public static void RegisterCommandHandlerAttributes(this SingleMessageHandlerRegistration registration,
136-
IEnumerable<CommandHandlerAttributeMethod> commandHandlerMethods)
120+
public static void RegisterCommandHandlersByAttribute(this SingleMessageHandlerRegistration registration,
121+
IEnumerable<CommandHandlerAttributeMethod> commandHandlerMethods)
137122
{
138123
if (registration == null)
139124
{

Tests/Xer.Cqrs.CommandStack.Extensions.Attributes.Tests/Registration/AttributeRegistrationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async Task ShouldRegisterAllMethodsOfTypeThatIsMarkedWithCommandHandlerAt
3232
var commandHandler = new TestAttributedCommandHandler(_outputHelper);
3333

3434
var registration = new SingleMessageHandlerRegistration();
35-
registration.RegisterCommandHandlerAttributes(() => commandHandler);
35+
registration.RegisterCommandHandlersByAttribute(() => commandHandler);
3636

3737
IMessageHandlerResolver resolver = registration.BuildMessageHandlerResolver();
3838

@@ -56,7 +56,7 @@ public async Task ShouldRegisterAllCommandHandlerAttributeMethodObjects()
5656
IEnumerable<CommandHandlerAttributeMethod> methods = CommandHandlerAttributeMethod.FromType(() => commandHandler);
5757

5858
var registration = new SingleMessageHandlerRegistration();
59-
registration.RegisterCommandHandlerAttributes(methods);
59+
registration.RegisterCommandHandlersByAttribute(methods);
6060

6161
IMessageHandlerResolver resolver = registration.BuildMessageHandlerResolver();
6262

@@ -79,7 +79,7 @@ public void ShouldNotAllowSyncMethodsWithCancellationToken()
7979
try
8080
{
8181
var registration = new SingleMessageHandlerRegistration();
82-
registration.RegisterCommandHandlerAttributes(() => new TestAttributedSyncCommandHandlerWithCancellationToken(_outputHelper));
82+
registration.RegisterCommandHandlersByAttribute(() => new TestAttributedSyncCommandHandlerWithCancellationToken(_outputHelper));
8383
}
8484
catch (Exception ex)
8585
{

0 commit comments

Comments
 (0)