Inheritance: ITransitionStorage
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            var container = new Container();
            DependencyResolver.SetResolver(new SmDependencyResolver(container));

            //
            // Service bus
            //
            var bus = ServiceBus.Run(c => c
                .SetServiceLocator(new StructureMapServiceLocator(container))
                .MemorySynchronousTransport()
                .SetName("Main  Service Bus")
                .SetInputQueue("sync.server")
                .AddEndpoint(type => type.FullName.EndsWith("Event"), "sync.server")
                .AddEndpoint(type => type.FullName.EndsWith("Command"), "sync.server")
                .AddEndpoint(type => type.FullName.EndsWith("Message"), "sync.server")
                .Dispatcher(d => d
                    .AddHandlers(typeof(UserAR).Assembly) 
                    .AddHandlers(typeof(UserEntityEventHandler).Assembly)
                 )
            );

            container.Configure(config => config.For<IServiceBus>().Singleton().Use(bus));

            // 
            // Domain and Event store configuration
            //
            var dataTypeRegistry = new AssemblyQualifiedDataTypeRegistry();


            var transitionsRepository = new InMemoryTransitionRepository();

            var transitionsStorage = new TransitionStorage(transitionsRepository);
            var snapshotRepository = new InMemorySnapshotRepository();

            container.Configure(config =>
            {
                config.For<ITransitionRepository>().Singleton().Use(transitionsRepository);
                config.For<ITransitionStorage>().Singleton().Use(transitionsStorage);
                config.For<CqrsSample.Infrastructure.Snapshots.ISnapshotRepository>().Singleton().Use(snapshotRepository);
                config.For<IDataTypeRegistry>().Singleton().Use(dataTypeRegistry);
                config.For<IEventStore>().Use<EventStore>();
                config.For<IEventBus>().Use<ParalectServiceBusEventBus>();
                config.For<IRepository>().Use<Repository>();
                config.For<ICommandService>().Use<CommandService>();
            });

        }
Exemplo n.º 2
0
 public static ITransitionStorage GetTransitionStorage()
 {
     var server = new TransitionStorage(GetTransitionRepository());
     return server;
 }