protected override void Load(ContainerBuilder builder) { builder.RegisterAssemblyTypes(typeof(IMediator).Assembly) .AsImplementedInterfaces(); // Register all the Command handler classes (they implement IRequestHandler) in assembly holding the Commands builder.RegisterAssemblyTypes(AssemblyExtensions.GetCommandHandlerAssemblies()) .AsClosedTypesOf(typeof(IRequestHandler <,>)); builder.RegisterAssemblyTypes(AssemblyExtensions.GetEventHandlerAssemblies()) .AsClosedTypesOf(typeof(INotificationHandler <>)); // Register the Command's Validators (Validators based on FluentValidation library) builder .RegisterAssemblyTypes(AssemblyExtensions.GetCommandHandlerAssemblies()) .Where(t => t.IsClosedTypeOf(typeof(IValidator <>))) .AsImplementedInterfaces(); builder.Register <ServiceFactory>(context => { var componentContext = context.Resolve <IComponentContext>(); return(t => componentContext.TryResolve(t, out var o) ? o : null); }); builder.RegisterGeneric(typeof(LoggingBehavior <,>)).As(typeof(IPipelineBehavior <,>)); builder.RegisterGeneric(typeof(ValidatorBehavior <,>)).As(typeof(IPipelineBehavior <,>)); builder.RegisterGeneric(typeof(TransactionBehaviour <,>)).As(typeof(IPipelineBehavior <,>)); }