Created
February 19, 2014 12:42
-
-
Save ShawInnes/9091220 to your computer and use it in GitHub Desktop.
Autofac Fluent Validation Module (MVC 5)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Autofac; | |
using FluentValidation; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace WebSite | |
{ | |
public class AutofacFluentValidationModule : Module | |
{ | |
protected override void Load(ContainerBuilder builder) | |
{ | |
AssemblyScanner findValidatorsInAssembly = AssemblyScanner.FindValidatorsInAssembly(typeof(Grunch.Validation.GroupOrderValidator).Assembly); | |
foreach (AssemblyScanner.AssemblyScanResult item in findValidatorsInAssembly) | |
{ | |
builder | |
.RegisterType(item.ValidatorType) | |
.Keyed<IValidator>(item.InterfaceType) | |
.As<IValidator>(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment