Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: Cannot implicitly convert type 'IocValidatorFactory' to 'FluentValidation.IValidatorFactory'

$
0
0
Hi Miguel,

I can't see anything obviously wrong there.

One thing you could try: cut and paste the methods from ValidatorFactoryBase into your class (not many there...) and make your class directly implement IValidatorFactory

https://fluentvalidation.codeplex.com/SourceControl/latest#src/FluentValidation/ValidatorFactoryBase.cs

Code below not tested at all!
 public class IocValidatorFactory : FluentValidation.IValidatorFactory {

    public IValidator CreateInstance(Type type) {
      return ObjectFactory.Container.TryGetInstance(type) as IValidator;
    } // CreateInstance

  public IValidator<T> GetValidator<T>() {
            return (IValidator<T>)GetValidator(typeof(T));
        }

        public IValidator GetValidator(Type type) {
            var genericType = typeof(IValidator<>).MakeGenericType(type);
            return CreateInstance(genericType);
        }


  } // IocValidatorFactory

Viewing all articles
Browse latest Browse all 1917

Trending Articles