Skip to content

Commit 79180cd

Browse files
committed
docs: clarify RegisterFromAssembly discovers open generic handlers automatically
1 parent fbf156d commit 79180cd

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,27 @@ public sealed class CommandLogger<T> : ICommandPreHandler<T> where T : ICommand
214214
}
215215
}
216216

217-
// Register the open generic type
217+
// RegisterFromAssembly automatically discovers open generic handlers in the assembly
218218
builder.Services.AddLiteBus(liteBus =>
219219
{
220220
liteBus.AddCommandModule(module =>
221221
{
222-
module.Register(typeof(CommandLogger<>)); // applies to ALL commands
222+
module.RegisterFromAssembly(typeof(Program).Assembly); // picks up CommandLogger<> too
223+
});
224+
});
225+
226+
// Or register explicitly if the handler is in a different assembly
227+
builder.Services.AddLiteBus(liteBus =>
228+
{
229+
liteBus.AddCommandModule(module =>
230+
{
231+
module.Register(typeof(CommandLogger<>)); // from an external library
223232
module.RegisterFromAssembly(typeof(Program).Assembly);
224233
});
225234
});
226235
```
227236

228-
LiteBus closes the generic at startup for each concrete message type. Generic constraints (`where T : ICommand`, `class`, `struct`, `new()`) are fully respected. Registration order does not matter.
237+
`RegisterFromAssembly` automatically discovers open generic handlers in the scanned assembly — no separate `Register(typeof(...))` call is needed. Use explicit registration only when the handler lives in a different assembly. LiteBus closes the generic at startup for each concrete message type. Generic constraints (`where T : ICommand`, `class`, `struct`, `new()`) are fully respected. Registration order does not matter.
229238

230239
### Advanced Eventing with Concurrency Control
231240

0 commit comments

Comments
 (0)