开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜