When registering a type to be constructed by a factory method, it is sometimes important to know what type the instance is being constructed for.
For example, when using log4net you might want to inject a logger for that specific type.
I knew how to do it using StructureMap:
For<ILog>().Use(s => LogManager.GetLogger(s.Root.ConcreteType));
But today I had to work out how to do it with Castle. (It’s pretty similar).
Component.For<ILog>().UsingFactoryMethod((k, cm, cc) => LogManager.GetLogger(cc.Handler.Service))