I can put a break point in the Select function, and the types being passed in 
looks OK - e.g. I get the SqlPlugInRepository type as expected, among other 
concrete types ending with "Repository".

One thing that I noticed was that the baseType passed as an argument in the 
Select method is always System.Object, even though this is not the direct base 
of the class in question - I don't know if it's supposed to be that way, but it 
seems strange.

Mark Seemann
http://blog.ploeh.dk<http://blog.ploeh.dk/>
(+45) 50 50 87 70

From: [email protected] 
[mailto:[email protected]] On Behalf Of Craig Neuwirt
Sent: 26. august 2009 20:04
To: [email protected]
Subject: Re: Auto-register all types that ends with a given string to their 
base class

What gets registered when you tried it?  Can you put a break point in the 
Select function and make sure the types are being passed in?
On Wed, Aug 26, 2009 at 11:00 AM, Mark Seemann 
<[email protected]<mailto:[email protected]>> wrote:
Thanks for your answer - I tried that as well, but that doesn't work either.

Regards

Mark Seemann

- Sent from my mobile device; hence the brevity.
________________________________
Fra: Craig Neuwirt <[email protected]<mailto:[email protected]>>
Sendt: 26. august 2009 17:25
Til: 
[email protected]<mailto:[email protected]>
 
<[email protected]<mailto:[email protected]>>
Emne: Re: Auto-register all types that ends with a given string to their base 
class
You probably need a custom selector like this

container.Register(AllTypes
   .FromAssemblyContaining<
SqlPlugInRepository>()
   .Where(t => t.Name.EndsWith("Repository"))
   .WithService.Select((t, b) => return new Type[] { t.BaseType })
      )

On Wed, Aug 26, 2009 at 10:03 AM, Mark Seemann 
<[email protected]<mailto:[email protected]>> wrote:

Hi all

I'm trying to auto-register all types in an assembly whose name ends
with "Repository". I expect all of these to derive from an abstract
base class that also ends with "Repository", and I'd like to register
them all.

As an example, I would like

public class SqlPlugInRepository : PlugInRepository { ... }

to be registered so that when I Resolve PlugInRepository, I get an
instance of SqlPlugInRepository.

I have tried this, but it doesn't work:

container.Register(AllTypes
   .FromAssemblyContaining<SqlPlugInRepository>()
   .Where(t => t.Name.EndsWith("Repository"))
   .WithService
   .Base());

Note that there is no common Repository supertype that all
Repositories derive from.

The abstract Repositories are defined in a different assembly than
their implmentations.

What am I doing wrong, and what should I be doing instead?

Thank you








--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to