Пример #1
0
        public virtual EventProperties Clone(ICloneManager cloneManager)
        {
            var clone = new EventProperties();

            EventMappings.Each(em => clone.AddEventMapping(em.Clone(cloneManager)));
            return(clone);
        }
Пример #2
0
        public virtual EventProperties Clone(ICloneManager cloneManager)
        {
            var clone = new EventProperties();

            clone.AddEventMappings(EventMappings.Select(x => x.Clone(cloneManager)));
            return(clone);
        }
        protected GesBaseTest()
        {
            Connection  = GetConnection().GetAwaiter().GetResult();
            AutoFixture = new Fixture();

            try
            {
                EventMappings.MapEventTypes();
            }
            catch (Exception e)
            {
                //ignore the already mapped events...
                Console.WriteLine(e);
            }
        }
Пример #4
0
 public TypeMapperFixture()
 {
     EventMappings.MapEventTypes();
 }
Пример #5
0
        private static void Main()
        {
            using (var container = new Container())
            {
                container.Options.AllowResolvingFuncFactories();
                // configuration appsettings convention
                IConfiguration config = new ConfigurationBuilder()
                                        .SetBasePath(Directory.GetCurrentDirectory())
                                        .AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
                                        .AddEnvironmentVariables()
                                        .Build();
                container.Options.RegisterParameterConvention(new AppSettingsConvention(key => config[key]));

                ILoggerFactory loggerFactory = new LoggerFactory()
                                               .AddConsole()
                                               .AddDebug();
                container.Options.DependencyInjectionBehavior = new MsContextualLoggerInjectionBehavior(loggerFactory, container);

                ILogger logger = loggerFactory.CreateLogger <Program>();
                //container.RegisterSingleton<ILogger>(logger);
                logger.LogInformation("Starting BC 'Ritten' host...");

                ExampleCQRS.Infrastructure.Registrations.InfrastructureModule.RegisterEventBus(container, config);

                DomainModule.RegisterAll(container);
                ApplicationModule.RegisterAll(container);
                InfrastructureModule.RegisterAll(container);
                InfrastructureModule.RegisterEventForwarder(container);
                RabbitMqModule.RegisterCommandConsumers(container);
                RabbitMqModule.RegisterEventConsumers(container);

                //ReadModel.Infrastructure.Registrations.InfrastructureModule.RegisterAll(container);

                container.RegisterSingleton(RabbitMqConfiguration.ConfigureBus((cfg, host) =>
                {
                    // command queue
                    //cfg.ReceiveEndpoint(host,
                    //    RabbitMqConstants.CommandsQueue, e =>
                    //    {
                    //        e.Handler<ICommand>(context =>
                    //        Console.Out.WriteLineAsync($"Command received : {context.Message.GetType()}"));
                    //        //e.LoadFrom(container);// TODO: prevent receiving same events
                    //    });
                    // events queue
                    cfg.ReceiveEndpoint(host, RabbitMqConstants.GetEventsQueue(BoundedContextName), e =>
                    {
                        e.Handler <IDomainEvent>(context =>
                                                 Console.Out.WriteLineAsync($"Event received : {context.Message.GetType()}"));
                        e.LoadFrom(container);
                    });
                }));

                EventMappings.Configure();

                var eventBus = container.GetInstance <IIntegrationEventBus>();
                eventBus.Subscribe <KmStandCreated, RitService>();

                //var bus = container.GetInstance<IBusControl>();

                //bus.StartAsync();

                Console.WriteLine("Listening for commands.. Press enter to exit");
                Console.ReadLine();

                //bus.StopAsync();
            }
        }