Using Castle Windsor with FluentValidation In MVC

Posted by user332022 on Stack Overflow See other posts from Stack Overflow or by user332022
Published on 2010-05-13T05:40:00Z Indexed on 2010/05/13 5:44 UTC
Read the original article Hit count: 659

Filed under:
|
|
|

I'm working on getting FluentValidation working with Castle Windsor. I already have a wrapper around Castle Windsor. Here is the code for that:

public class ResolveType { private static IWindsorContainer _windsorContainer;

    public static void Initialize( IWindsorContainer windsorContainer )

{ _windsorContainer = windsorContainer; }

public static T Of() { return _windsorContainer.Resolve(); } }

I am trying to build the FluentValidation factory as is explained at http://www.jeremyskinner.co.uk/2010/02/22/using-fluentvalidation-with-an-ioc-container

The article uses StructureMap, but I thought I could adapt it to Castle Windsor like this:

public class CastleWindsorValidatorFactory : ValidatorFactoryBase {

public override IValidator CreateInstance( Type validatorType) { return ResolveType.Of(); } }

Notice, I'm just trying to call into my wrapper so that Windsor can resolve the type reference.

The problem is that this doesn't compile. I get 'The type or namespace name 'validatorType' could not be found (are you missing a using directive or an assembly reference?)'

How can I make this work?

© Stack Overflow or respective owner

Related posts about mvc

Related posts about castle