I should really learn to read exception messages CAREFULLY!

It turned out that the type that couldn't be resolved was a different
type that just had enough semantic similarity with the other type that
I didn't discover this before today. Once I realized this, I was
quickly able to resolve my issue.

You answer was still very helpful, though, as I couldn't really figure
out whether I was on the right track at all, and at least I now know
that I have to use the Select method and not the Base method :)

Thank you for your help

On Aug 27, 12:05 am, Craig Neuwirt <[email protected]> wrote:
> On Wed, Aug 26, 2009 at 3:33 PM, Mark Seemann <[email protected]> wrote:
> >  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".
>
> Hmm.  That should work then since your just returning the BaseType for the
> interface.
>
> >  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.
>
> Thats expected.  The baseType really should be called basedOnType.  It is
> what was passed to AllTypes.BasedOn<PluginRepository>.  Since you used a
> where claused, the baseType defaults to System.Object
>
> Can you create a test case that presents the issue?
>
>
>
>
>
> > Mark Seemann
>
> >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]> 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]>
> > *Sendt: *26. august 2009 17:25
> > *Til: *[email protected] <
> > [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]> 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- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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