【问题标题】:IoC (Windsor) - What is a "Default Interface"?IoC (Windsor) - 什么是“默认界面”?
【发布时间】:2011-11-18 15:32:20
【问题描述】:

谁能解释一下两者的区别

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

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

“默认界面”是什么意思?

【问题讨论】:

    标签: inversion-of-control castle-windsor


    【解决方案1】:

    looks for an implementation of an interface by removing the leading I:

    • IFoo -> Foo
    • IBar -> 酒吧
    • IKitchenSink -> 厨房水槽

    但是,在我看来,使用此功能有点像over-abundance of 1:1 interfaces

    【讨论】:

    • 好的,但是 1:1 的重点不是组件/服务的 DI,这些组件/服务只有一个(可插入的)此应用程序实例的实现(无论是测试夹具还是 Web app) - 重点是:可插拔性?
    • 实际上它也可以匹配类似的东西:IFoo--> MarksSuperFoo 基本上它看起来,在你删除领先的I之后,类名包含接口名称
    猜你喜欢
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2016-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-23
    • 1970-01-01
    相关资源
    最近更新 更多