Ok, now I get

No component for supporting the service IValidator`1[[UserDetail,
Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] was
found

If I use WithService.DefaultInterface or Base the code passes, but
it's almost like the underlying base class is getting called instead
of the appropriate subclass...

I'm not sure exactly what you mean by "configure some service
overrides".

On Feb 11, 11:06 am, Patrick Steele <[email protected]> wrote:
> I think the problem is that you're using
> "WithService.AllInterfaces()".  This will register AddressValidator
> and UserDetailValidator as IValidator<> services.  When you try and
> resolve UserDetailValidator, the ctor needs an AddressValidator.
> There isn't one registered -- there's two IValidator<T>'s registered,
> but your ctor wants an AddressValidator.
>
> If you take out the WithService.AllInterfaces(), you should be okay.
> But if you want other components to depend on an IValidator<T>, you'll
> probably need to configure some service overrides so Windsor knows
> which one of your multiple IValidator<T>'s to use.
>
> I think...  :)
>
> ---
> Patrick Steelehttp://weblogs.asp.net/psteele
>
>
>
>
>
>
>
> On Sat, Feb 11, 2012 at 9:27 AM, Steven <[email protected]> wrote:
> > Yes, BaseValidator<T> does inherit from IValidator<T>
>
> > public abstract class BaseValidator<T> : AbstractValidator<T>,
> > IValidator<T>
>
> > where AbstractValidator is a 3rd party lib base class (Jeremy Skinners
> > FluentValidation).
>
> > On Feb 11, 9:21 am, Patrick Steele <[email protected]> wrote:
> >> What does BaseValidator<T> look like?  Does it implement IValidator<T>?
>
> >> ---
> >> Patrick Steelehttp://weblogs.asp.net/psteele
>
> >> On Sat, Feb 11, 2012 at 7:31 AM, Steven <[email protected]> wrote:
> >> > I have two classes that inherit from the same base class.
>
> >> >    public class UserDetailValidator : BaseValidator<UserDetail>{
> >> >                public UserDetailValidator(IRepository<Person, Guid> 
> >> > userRepository,
> >> > AddressValidator addressValidator)
> >> >                {
> >> >                        RuleFor(x => x.FirstName).Length(1, 10);
> >> >                }
> >> >    }
>
> >> >    public class AddressValidator : BaseValidator<Address>
>
> >> > When I try and get the UserDetailValidator from WindsorServiceLocator
> >> > I get the error
>
> >> > Missing dependency.
> >> > Component UserDetailValidator has a dependency on AddressValidator,
> >> > which could not be resolved.
> >> > Make sure the dependency is correctly registered in the container as a
> >> > service, or provided as inline argument.  I'm using the following in
> >> > my ValidationInstaller.
>
> >> >    container.Register(
> >> >        AllTypes.FromAssemblyNamed("Validation")
> >> >                .IncludeNonPublicTypes()
> >> >                .BasedOn(typeof(IValidator<>))
> >> >                .WithService.AllInterfaces()
> >> >                .LifestyleTransient()
>
> >> > The IRepository component is being injected with no problems.  It's
> >> > only the AddressValidator that does not come in.  What am I not doing
> >> > properly?
>
> >> > --
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Castle Project Development List" 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 
> >> > athttp://groups.google.com/group/castle-project-devel?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Castle Project Development List" 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 
> > athttp://groups.google.com/group/castle-project-devel?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en.

Reply via email to