I have a collection of services that I want to register with Castle Windsor (version 3.0 RC1) using the fluent registration technique.
I want all of them except for a particular one to use the transient lifestyle and that one I want to be a singleton, so I do this:
container.Register(AllTypes
.FromThisAssembly()
.InSameNamespaceAs<IMyService>()
.WithServiceDefaultInterfaces()
.ConfigureIf(s => s.Implementation == typeof(MyService),
s => s.LifestyleSingleton(),
s => s.LifestyleTransient()));
The problem I have with that is that I am using typeof(MyService) in the first parameter of ConfigureIf, but I would prefer it if I could use IMyService to determine whether it is a singleton or not (i.e. it does not matter what the implementation is, it should always be a singleton). Is that somehow possible?