2010-06-28 40 views
1

如何寫這個StructureMap線NinjectStructureMap到Ninject規則

 ForRequestedType<HttpContextBase>() 
      .TheDefault.Is.ConstructedBy(x => new HttpContextWrapper(HttpContext.Current)); 

回答

5
Bind<HttpContextBase>().ToMethod(context => new HttpContextWrapper(HttpContext.Current)); 
+0

委託 'System.Func ' 不採取0參數 – mare 2010-06-28 18:54:56

+1

@mare:固定錯字 – 2010-06-28 21:50:21

+0

啊,糟糕。我使用了一個帶有零參數的lambda表達式。感謝編輯Ruben。 – 2010-06-29 13:35:18