I'm curious as to the difference between these two methods. I'm implementing a decorator pattern with open generics and whether I use AddAllTypesOf
or ConnectImplementationsToTypesClosing
it doesn't matter, I get the same functionality.
public class CommandRegistry : Registry
{
public CommandRegistry()
{
For<CommandProcessor>().Use<DefaultCommandProcessor>().Transient();
Scan(scanner =>
{
scanner.AssemblyContainingType<SaveCoolCommandHandler>();
//scanner.AddAllTypesOf(typeof(CommandHandler<>));
//scanner.AddAllTypesOf(typeof(IValidator<>));
//scanner.AddAllTypesOf(typeof(LogMehh<>));
scanner.ConnectImplementationsToTypesClosing(typeof(CommandHandler<>));
scanner.ConnectImplementationsToTypesClosing(typeof(IValidator<>));
scanner.ConnectImplementationsToTypesClosing(typeof(LogMehh<>));
});
var handlerType = For(typeof(CommandHandler<>));
handlerType.DecorateAllWith(typeof(CommandValidator<>)); //Second
handlerType.DecorateAllWith(typeof(CommandLogger<>)); //First
// ObjectFactory.WhatDoIHave();
}
}
The call to ObjectFactory.WhatDoIHave()
also gives me the same results no matter which method I choose.
I've looked at the source code and these methods are definately doing different things, I just haven't been able to determine exactly what the difference is. Are there any guidelines or scenarios when one is preferred over the other?