1

Basically I would like a way to express: Find all classes with base class AbstractDataService<> and resolve them by their interface 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?

2
  • Looks good to me... why do you say it's not elegant? Nov 21, 2010 at 23:29
  • @Mauricio Scheffer: I am missing something like HasBaseOf(typeof(AbstractDataService<>)).
    – the_drow
    Nov 22, 2010 at 8:08

2 Answers 2

1

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

1
  • But BasedOn for some reason returns all of the types in my namespace if I ommit .If(Component.IsInSameNamespaceAs(typeof(AbstractDataService<>))).
    – the_drow
    Nov 23, 2010 at 10:21
0

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

1
  • But even complex things can be simplified through helpers I don't know of.
    – the_drow
    Nov 22, 2010 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.