开发者

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

开发者 https://www.devze.com 2023-01-26 08:03 出处:网络
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.

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

精彩评论

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