Пример #1
0
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            var viewmodel       = new InMemoryViewModelRepository();
            var snapshotPath    = ConfigurationManager.AppSettings["snapshotPath"];
            var snapshotVersion = ConfigurationManager.AppSettings["snapshotVersion"];
            var streamName      = ConfigurationManager.AppSettings["streamName"];

            var snapshottingDispatcher = new ProtoBufSnapshottingResolvedEventDispatcher(() =>
            {
                var repo = (container.Resolve <IViewModelReader>() as InMemoryViewModelRepository);
                return(GetPairs(repo));
            }, snapshotPath, snapshotVersion);

            var items         = snapshottingDispatcher.LoadObjects();
            int?startingEvent = snapshottingDispatcher.LoadCheckpoint();

            //add the items to the viewmodel
            foreach (var dynamicItem in items.Select(item => item as dynamic))
            {
                viewmodel.Add(dynamicItem.Key, dynamicItem.Value);
            }

            ViewModelLoaded(viewmodel);
            //event store
            var esLogger = new EventStoreLogaryLogger();
            var conn     = SetUpEventStoreConnection("EventStoreConnection", esLogger);

            container.Register(conn);

            //aggregate repository
            container.Register <IAggregateRepository, EventStoreAggregateRepository>();

            container.Register <IViewModelReader>(viewmodel);
            container.Register <IViewModelWriter>(viewmodel);

            var multiplexingDispatcher = new MultiplexingDispatcher <ResolvedEvent>(GetDispatchers(container).ToArray());

            snapshottingDispatcher.InnerDispatcher = multiplexingDispatcher;

            var loggingDispatcher = new ErrorLoggingDispatcher(snapshottingDispatcher, false);

            container.Register <IDispatcher <ResolvedEvent> >(loggingDispatcher);

            var subscriber = new EventStoreSubscriber(conn, loggingDispatcher, streamName, esLogger, startingEvent, 4096, 70000);

            container.Register(subscriber);
        }
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            var viewmodel = new InMemoryViewModelRepository();
            var snapshotPath = ConfigurationManager.AppSettings["snapshotPath"];
            var snapshotVersion = ConfigurationManager.AppSettings["snapshotVersion"];
            var streamName = ConfigurationManager.AppSettings["streamName"];

            var snapshottingDispatcher = new ProtoBufSnapshottingResolvedEventDispatcher(() =>
            {
                var repo = (container.Resolve<IViewModelReader>() as InMemoryViewModelRepository);
                return GetPairs(repo);
            }, snapshotPath, snapshotVersion);

            var items = snapshottingDispatcher.LoadObjects();
            int? startingEvent = snapshottingDispatcher.LoadCheckpoint();
            //add the items to the viewmodel
            foreach (var dynamicItem in items.Select(item => item as dynamic))
                viewmodel.Add(dynamicItem.Key, dynamicItem.Value);

            ViewModelLoaded(viewmodel);
            //event store
            var esLogger = new EventStoreLogaryLogger();
            var conn = SetUpEventStoreConnection("EventStoreConnection", esLogger);
            container.Register(conn);

            //aggregate repository
            container.Register<IAggregateRepository, EventStoreAggregateRepository>();

            container.Register<IViewModelReader>(viewmodel);
            container.Register<IViewModelWriter>(viewmodel);

            var multiplexingDispatcher = new MultiplexingDispatcher<ResolvedEvent>(GetDispatchers(container).ToArray());
            var commandDispatcher = new CommmandDispatcher(new MultiplexingDispatcher<object>(GetCommandDispatchers(container).ToArray()));

            snapshottingDispatcher.InnerDispatcher = multiplexingDispatcher;

            var loggingDispatcher = new ErrorLoggingDispatcher(snapshottingDispatcher, false);

            container.Register<IDispatcher<ResolvedEvent>>(loggingDispatcher);

            var subscriber = new EventStoreSubscriber(conn, loggingDispatcher, streamName, esLogger, startingEvent, 4096, 70000);

            container.Register(subscriber);
            container.Register<ICommandDispatcher>(commandDispatcher);
        }