Exemple #1
0
        public static ConsoleEnvironment Build()
        {
            var handler = new SynchronousEventHandler();

            var inbox = new InboxProjection();
            handler.RegisterHandler(inbox);

            //var store = new InMemoryStore(handler);

            var store = new FileAppendOnlyStore(new DirectoryInfo(Directory.GetCurrentDirectory()));
            store.Initialize();
            var messageStore = new MessageStore(store);
            messageStore.LoadDataContractsFromAssemblyOf(typeof(ActionDefined));
            var currentVersion = store.GetCurrentVersion();
            var log = LogManager.GetLoggerFor<ConsoleEnvironment>();
            log.Debug("Event Store ver {0}", currentVersion);

            if (currentVersion > 0)
            {
                log.Debug("Running in-memory replay");
                foreach (var record in messageStore.EnumerateAllItems(0, int.MaxValue))
                {
                    foreach (var item in record.Items.OfType<Event>())
                    {
                        handler.Handle(item);
                    }
                }
                log.Debug("Replay complete");
            }

            var events = new EventStore(messageStore,handler);

            var tenant = new TenantAppService(events, new RealTimeProvider());
            var build = new ConsoleEnvironment
                {
                    Store = events,
                    Tenant = tenant,
                    Commands = ConsoleCommands.Actions,
                    Id = new TenantId(1),
                    Inbox = inbox
                };
            return build;
        }
Exemple #2
0
 //static ILogger Log = LogManager.GetLoggerFor<InMemoryStore>();
 public InMemoryStore(SynchronousEventHandler eventHandler)
 {
     _eventHandler = eventHandler;
 }