2011-11-18 59 views
5

能有人請解釋什麼是 「默認界面」 的意思IoC(Windsor) - 什麼是「默認界面」?

container.Register(AllTypes.FromAssemblyContaining(typeof(BigCompanyRepository)) 
.WithService.DefaultInterface() 

container.Register(AllTypes.FromAssemblyContaining(typeof(BigCompanyRepository)) 
.WithService.AllInterfaces() 

之間的區別?

回答

6

就這麼looks for an implementation of an interface by removing the leading I啓發:

  • 的IFoo - >富
  • 伊巴爾 - >酒吧
  • IKitchenSink - >的KitchenSink

然而,在我看來,使用此功能的氣味的over-abundance of 1:1 interfaces

+1

ok,但不是1:1組件/服務的DI,它只有一個(可插入的)實現用於此應用程序實例(無論是測試夾具還是Web應用程序) - 點是:可插拔性? –

+9

實際上,它也可以匹配如下內容:'IFoo' - >'MarksSuperFoo'基本上看起來,在刪除前導'I'後,類名__contains__的接口名稱 –