【问题标题】:StructureMap EnrichWith without specifying concrete classStructureMap EnrichWith 不指定具体类
【发布时间】:2013-04-24 17:49:53
【问题描述】:

我有三个程序集:

  1. 接口
  2. 实现
  3. 授权

我的授权程序集包含不同接口和实现的装饰器。

我知道我可以在装饰中使用类似的东西:

For<ISomething>
.Use<ConcreteSomething>
.EnrichWith<ISomething>((ctx, r) => new ConcreteSomethingDecorator));

但在我的情况下,我的 Implementations 程序集中有一个注册表,而我的 Authorizations 程序集中有一个注册表。 (我不希望我的 Authorization and Implementations 程序集知道另一个)。

我不希望我的 Authorizations 程序集引用 Implementations 程序集,所以我正在寻找类似的东西:

For<ISomething>
.EnrichWith<ISomething>((ctx, r) => new ConcreteSomethingDecorator));

在我的引导程序中,我想使用标志添加 AuthorizationRegistry 以在调试模式下跳过它。

我的问题(终于!):是否可以在不指定具体类的情况下丰富接口?

【问题讨论】:

    标签: decorator structuremap


    【解决方案1】:

    我找到了方法!

    只需使用 EnrichAllWith 代替 EnrichWith!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-23
      • 1970-01-01
      相关资源
      最近更新 更多