Castle Windsor + ISubDependencyResolver: weird issues
Castle Windsor 2.5. This fails. Why? Is it designated beahvior or a bug? Seems sub dependency resolvers are not even queried when resolving top-level services.
class Program
{
class Resolver :ISubDependencyResolver
{
public object Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
{
return new Program();
}
public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
{
return dependency.开发者_运维百科TargetType == typeof (Program);
}
}
[STAThread]
static void Main()
{
var container = new WindsorContainer();
container.Kernel.Resolver.AddSubResolver(new Resolver());
var xxx = container.Resolve<Program>();
}
}
These are sub dependency resolvers. They resolve dependencies, not root services. What are you really trying to do? Why not register the object upfront?
精彩评论