public override IUnitOfWorkScope BeginUnitOfWork()
        {
            var connection = new SQLiteConnection(this.ConnectionString, true);
            var scope      = new SqlUnitOfWorkScope(connection);

            scope.RegisterObject <IEventStore>(new EventStore(connection, this.EventSerializer));

            if (this.CommandSerializer != null)
            {
                scope.RegisterObject <IPendingCommandRepository>(new PendingCommandRepository(connection, this.CommandSerializer));
                scope.RegisterObject <IRepository <ISyncState> >(new SyncStateRepository(connection));
            }

            if (this.SnapshotSerializer != null)
            {
                scope.RegisterObject <ISnapshotRepository>(new SnapshotRepository(connection, this.SnapshotSerializer));
            }

            if (!string.IsNullOrWhiteSpace(this.ReadModelConnectionString))
            {
                if (this.readModelQueue == null)
                {
                    this.readModelQueue = new ReadModelBuilderQueue(this.readModelConnection);
                }

                scope.RegisterObject <IReadModelQueueProducer>(this.readModelQueue);
            }

            return(scope);
        }
        public void StartDelayedReadModels()
        {
            if (!string.IsNullOrWhiteSpace(this.ReadModelConnectionString) && this.BuilderAgent == null)
            {
                if (this.readModelQueue == null)
                {
                    this.readModelQueue = new ReadModelBuilderQueue(this.readModelConnection);
                }

                this.BuilderAgent = new ReadModelBuilderAgent(
                    this,
                    this.Registrations.ToList(),
                    () => new SqlUnitOfWorkScope(this.readModelConnection),
                    (scope) => this.readModelQueue);

                this.BuilderAgent.Start();
            }
        }