I have a windsor facility that I need to use to add a forward to a registered component. For some reason I can't seem to figure out how to do this.
I have the ComponentRegistered
event bound and I'm able to filter out what I need to add the additional interface to but I can't seem to add the forward. Here is what I have in my facility:
void KernelComponentRegistered(string key, IHandler handler)
{
if (typeof(ICanDoMagic).IsAssignableFrom(handler.ComponentModel.Implementation))
{
// I don't know what goes here
}
}
protected override void Init()
{
Kernel.ComponentRegistered += KernelComponentRegistered;
}
and I have the following interfaces and class:
public interface ICanDoMagic
public interface IBasicInterface
public class BasicClass : IBasicInterface, ICanDoMagic
and here is the registration with windsor
container.Register(Component.For<IBasicInterface>().ImplementedBy<BasicClass>())
What I want to have happen is when the user registers things that implement ICanDoMagic (like I have in the registration above) I want to also register the ICanDoMagic interface for that class so they don't need to register it themselves. I think this is done with a forward but I don't know how to add it.
You want to attach to
Kernel.ComponentModelCreated
instead. This code will then work for you:This is somewhat similar to this question.