Exemplo n.º 1
0
        public static ITestContext CreateDefault()
        {
            Func<IDomainRepository> domainRepositoryFn = null;

            var builder = new CqrsRuntimeBuilder();
            builder.CommandHandlerContainerFactory = t => Activator.CreateInstance(t, domainRepositoryFn.Invoke());
            builder.EventHandlerContainerFactory = Activator.CreateInstance;

            var commandHandlersConfig = new AssemblyScanConfig(typeof(AllCommandHandlers).Assembly);
            var subCommandHandlersConfig = new AssemblyScanConfig(typeof (AllSubCommandHandlers).Assembly)
            {
                NamespaceFilter = n => n.Contains("SubCommandHandlers")
            };
            var eventHandlersConfig = new AssemblyScanConfig(typeof(AllEventHandlers).Assembly);
            var subEventHandlersConfig = new AssemblyScanConfig(typeof(AllSubEventHandlers).Assembly)
            {
                NamespaceFilter = n => n.Contains("SubEventHandlers")
            };
            var denormalizersConfig = new AssemblyScanConfig(typeof(AllDenormalizers).Assembly)
            {
                NamespaceFilter = n => n != null && n.EndsWith("Denormalizers")
            };
            var subDenormalizersConfig = new AssemblyScanConfig(typeof(AllSubDenormalizers).Assembly)
            {
                NamespaceFilter = n => n != null && n.Contains("SubDenormalizers")
            };

            var cqrsRuntime = builder.Build(
                new[] { commandHandlersConfig, subCommandHandlersConfig },
                new[] { eventHandlersConfig, subEventHandlersConfig, denormalizersConfig, subDenormalizersConfig });
            domainRepositoryFn = cqrsRuntime.GetDomainRepository;

            return new TestContext(cqrsRuntime);
        }
        public AssemblyCommandHandlerResolver(AssemblyScanConfig config)
        {
            Ensure.That(config, "config").IsNotNull();

            CommandMarkerType = typeof (ICommand);
            Assembly = config.Assembly;
            NamespaceFilter = config.NamespaceFilter ?? (n => n != null && n.EndsWith("CommandHandlers"));
        }
Exemplo n.º 3
0
        public AssemblyCommandHandlerResolver(AssemblyScanConfig config)
        {
            Ensure.That(config, "config").IsNotNull();

            CommandMarkerType = typeof(ICommand);
            Assembly          = config.Assembly;
            NamespaceFilter   = config.NamespaceFilter ?? (n => n != null && n.EndsWith("CommandHandlers"));
        }
Exemplo n.º 4
0
        public static ITestContext CreateDefault()
        {
            Func <IDomainRepository> domainRepositoryFn = null;

            var builder = new CqrsRuntimeBuilder();

            builder.CommandHandlerContainerFactory = t => Activator.CreateInstance(t, domainRepositoryFn.Invoke());
            builder.EventHandlerContainerFactory   = Activator.CreateInstance;

            var commandHandlersConfig    = new AssemblyScanConfig(typeof(AllCommandHandlers).Assembly);
            var subCommandHandlersConfig = new AssemblyScanConfig(typeof(AllSubCommandHandlers).Assembly)
            {
                NamespaceFilter = n => n.Contains("SubCommandHandlers")
            };
            var eventHandlersConfig    = new AssemblyScanConfig(typeof(AllEventHandlers).Assembly);
            var subEventHandlersConfig = new AssemblyScanConfig(typeof(AllSubEventHandlers).Assembly)
            {
                NamespaceFilter = n => n.Contains("SubEventHandlers")
            };
            var denormalizersConfig = new AssemblyScanConfig(typeof(AllDenormalizers).Assembly)
            {
                NamespaceFilter = n => n != null && n.EndsWith("Denormalizers")
            };
            var subDenormalizersConfig = new AssemblyScanConfig(typeof(AllSubDenormalizers).Assembly)
            {
                NamespaceFilter = n => n != null && n.Contains("SubDenormalizers")
            };

            var cqrsRuntime = builder.Build(
                new[] { commandHandlersConfig, subCommandHandlersConfig },
                new[] { eventHandlersConfig, subEventHandlersConfig, denormalizersConfig, subDenormalizersConfig });

            domainRepositoryFn = cqrsRuntime.GetDomainRepository;

            return(new TestContext(cqrsRuntime));
        }