开发者

Is there a better way to express this fluent registration in Windsor?

Basically I would like a way to express: Find all classes with base class AbstractDataService<> and resolve them by their in开发者_开发问答terface and not by their base class.

I currently have this and it works but it isn't very elegant:

container.Register(AllTypes.Pick()
   .FromAssembly(typeof(AbstractDataService<>).Assembly)
   .If(Component.IsInSameNamespaceAs(typeof(AbstractDataService<>)))
   .WithService.FirstInterface());

Is it possible?


Maybe you could use .BasedOn(...)?


You can create intermediate variables. But...I'm not really sure what the real problem is. Complex things look complex. This is reality.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜