示例#1
0
 public CompositionRootFixture()
 {
     HttpContext.Current = null;
     Container = new Container();
     var assemblies = new[] { Assembly.GetExecutingAssembly() };
     var settings = new RootCompositionSettings
     {
         FluentValidatorAssemblies = assemblies,
         QueryHandlerAssemblies = assemblies,
         CommandHandlerAssemblies = assemblies,
     };
     Container.ComposeRoot(settings);
 }
示例#2
0
        public CompositionRootFixture()
        {
            HttpContext.Current = null;
            Container           = new Container();
            var assemblies = new[] { Assembly.GetExecutingAssembly() };
            var settings   = new RootCompositionSettings
            {
                FluentValidatorAssemblies = assemblies,
                QueryHandlerAssemblies    = assemblies,
                CommandHandlerAssemblies  = assemblies,
            };

            Container.ComposeRoot(settings);
        }
示例#3
0
        public static void ComposeRoot(this Container container, RootCompositionSettings settings)
        {
            settings = settings ?? new RootCompositionSettings();
#if !DEBUG
            settings.IsGreenfield = false;
#endif
            container.Register<IServiceProvider>(() => container, Lifestyle.Singleton);
            container.RegisterConfiguration();
            container.RegisterCryptography();
            container.RegisterExceptionAuditor();
            container.RegisterMailDelivery();
            container.RegisterEntityFramework(settings.IsGreenfield);
            container.RegisterSecurity();
            container.RegisterFluentValidation(settings.FluentValidatorAssemblies);
            container.RegisterQueryTransactions(settings.QueryHandlerAssemblies);
            container.RegisterCommandTransactions(settings.CommandHandlerAssemblies);
        }
示例#4
0
        public static void ComposeRoot(this Container container, RootCompositionSettings settings)
        {
            settings = settings ?? new RootCompositionSettings();
#if !DEBUG
            settings.IsGreenfield = false;
#endif
            container.Register <IServiceProvider>(() => container, Lifestyle.Singleton);
            container.RegisterConfiguration();
            container.RegisterCryptography();
            container.RegisterExceptionAuditor();
            container.RegisterMailDelivery();
            container.RegisterEntityFramework(settings.IsGreenfield);
            container.RegisterSecurity();
            container.RegisterFluentValidation(settings.FluentValidatorAssemblies);
            container.RegisterQueryTransactions(settings.QueryHandlerAssemblies);
            container.RegisterCommandTransactions(settings.CommandHandlerAssemblies);
        }
示例#5
0
        public static void Configure()
        {
            var container = new Container();
            var settings = new RootCompositionSettings
            {
#if DEBUG
                IsGreenfield = true,
#endif
                FluentValidatorAssemblies = new[]
                {
                    Assembly.GetAssembly(typeof(IHandleCommand<>)),
                    Assembly.GetExecutingAssembly(),
                },
            };
            container.ComposeRoot(settings);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcAttributeFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
            GlobalConfiguration.Configuration.DependencyResolver = new WebApiDependencyResolver(container);

            FluentValidation.Mvc.FluentValidationModelValidatorProvider.Configure(
                provider =>
                {
                    provider.ValidatorFactory = new ValidatorFactory(container);
                    provider.AddImplicitRequiredValidator = false;
                }
            );
            FluentValidation.Mvc.WebApi.FluentValidationModelValidatorProvider.Configure(provider =>
            {
                provider.ValidatorFactory = new ValidatorFactory(container);
            });
        }