Castle Windsor的MVC3的例子在最新版本(3.0Beta)上编译不过去的解决办法

编译不过去的代码:

  public void Install(IWindsorContainer container, IConfigurationStore store)
  {
   container.Register(AllTypes.FromThisAssembly()
                       .BasedOn<IController>()
                       .If(Component.IsInSameNamespaceAs<HomeController>())
                       .If(t => t.Name.EndsWith("Controller"))
                       .Configure((c => c.LifeStyle.Transient)));
  }

提示信息:

错误 1 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句 *******\ControllersInstaller.cs 21 50 ******

修改成这个样子即可:

  public void Install(IWindsorContainer container, IConfigurationStore store)
  {
   container.Register(AllTypes.FromThisAssembly()
                       .BasedOn<IController>()
                       .If(Component.IsInSameNamespaceAs<HomeController>())
                       .If(t => t.Name.EndsWith("Controller"))
                       .Configure((c => c.LifestyleTransient())));
  }

posted @ 2011-11-28 20:08  悠闲的水  阅读(449)  评论(0编辑  收藏  举报