Batch registration sometimes requires to call the GetTypesToRegister method, which can be a hassle and this method is hard to find. Instead of using GetTypesToRegister this could be integrated in the Register method by adding one or multiple overloads that accept a TypesToRegisterOptions argument.
So instead of doing this:
var types =
container.GetTypesToRegister(typeof(IRequestHandler<,>), assemblies,
new TypesToRegisterOptions
{
IncludeGenericTypeDefinitions = true
});
container.Register(typeof(IRequestHandler<,>), types);
We could do this:
container.Register(typeof(IRequestHandler<,>), assemblies, new TypesToRegisterOptions
{
IncludeGenericTypeDefinitions = true
});
Batch registration sometimes requires to call the
GetTypesToRegistermethod, which can be a hassle and this method is hard to find. Instead of usingGetTypesToRegisterthis could be integrated in theRegistermethod by adding one or multiple overloads that accept aTypesToRegisterOptionsargument.So instead of doing this:
We could do this: