ISagaRepository <T> ISagaRepositoryFactory.CreateSagaRepository <T>()
        {
            var repository = _container.GetInstance <ISagaRepository <T> >();

            var scopeProvider = new StructureMapSagaScopeProvider <T>(_container);

            scopeProvider.AddScopeAction(x => x.GetOrAddPayload <IStateMachineActivityFactory>(() => new StructureMapStateMachineActivityFactory()));

            return(new ScopeSagaRepository <T>(repository, scopeProvider));
        }
        ISagaRepository <T> ISagaRepositoryFactory.CreateSagaRepository <T>(Action <ConsumeContext> scopeAction)
        {
            var repository = _container.GetInstance <ISagaRepository <T> >();

            var scopeProvider = new StructureMapSagaScopeProvider <T>(_container);

            if (scopeAction != null)
            {
                scopeProvider.AddScopeAction(scopeAction);
            }

            return(new ScopeSagaRepository <T>(repository, scopeProvider));
        }