Hi,
public class ICommand {}
public class ICommandHandler<TCommand> {
void Handle(TCommand command);
}
public abstract class BaseCommandHandler<TCommand> :
ICommandHandler<TCommand> where TCommand : ICommand {
public NHibernate Session {get;set;}
public abstract void Handle(TCommand command);
}
public class AuthorizedCommandHandler<TCommand> : ICommandHandler<TCommand>
where TCommand : ICommand {
private readonly ICommandHandler<TCommand> _innerCommandHandler;
public AuthorizedCommandHandler(ICommandHandler<TCommand>
innerCommandHandler) {
_innerCommandHandler = innerCommandHandler;
}
public void Handle(TCommand command) {
_innerCommandHandler.Handle(command);
}
}
public class TestCommandHandler : ICommandHandler<XCommand> {
public override void Handle(XCommand command) {
// execute command
}
}
I register my handler:
Container.Register(Component.For(typeof(ICommandHandler<>))
.ImplementedBy(typeof(AuthorizedCommandHandler<>)));
Container.Register(
Types
.From(metadataProviderContributorsAssemblies.SelectMany(a =>
a.GetExportedTypes()))
.BasedOn(typeof(ICommandHandler<>))
.WithService.Base());
when I resolve using ICommandHandler like this:
Container.Resolve<ICommandHandler<XCommand>>(), castle windsor return
TestCommandHandler, but I need AuthorizedCommandHandler(TestCommandHandler)
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/groups/opt_out.