I have a MixIn that requires some state to operate.
I am registering it as so..
container.Register(Component.For(Of ICat) _
.ImplementedBy(Of Cat) _
.LifeStyle.Transient _
.Proxy.MixIns(New MyMixin()))
When I call container.Resolve(of ICat), I get back a proxy for ICat, which also implements IMixin.
However, if I call container.Resolve(of ICat) again, I get a new proxy for ICat, but MyMixin is the SAME instance. (Which makes sense because I didn't tell the container any way to create IMixin)
So, IMixin is a Singleton, even though the Component's lifestyle is Transient.
How can I tell Windsor, though the Fluent Interface, to create a new Instance of MyMixIn for the component?
I'm not sure how it bubbles up to Windsor, but at DynamicProxy level, there's mixin Instance per proxy type. So if you're creating yourself mixin instances, you may be also each time be generating a new proxy type. To circumvent this, override Equals and GetHashCode in your mixed in type.
I may however not be right, so you may want to make sure first.
I think I resolved this.
Instead of using Proxy.Mixins, I created a custom Activator()
So now, the component is registered like this
And IMixin is registered as follows