public InMemorySagaRepositoryContext(IndexedSagaDictionary <TSaga> sagas, ISagaConsumeContextFactory <IndexedSagaDictionary <TSaga>, TSaga> factory, ConsumeContext <TMessage> context) : base(context) { _sagas = sagas; _factory = factory; _context = context; _sagasLocked = true; }
public async Task <SagaConsumeContext <TSaga, T> > CreateSagaConsumeContext <T>(IndexedSagaDictionary <TSaga> context, ConsumeContext <T> consumeContext, TSaga instance, SagaConsumeContextMode mode) where T : class { SagaInstance <TSaga> sagaInstance; switch (mode) { case SagaConsumeContextMode.Add: case SagaConsumeContextMode.Insert: sagaInstance = new SagaInstance <TSaga>(instance); await sagaInstance.MarkInUse(consumeContext.CancellationToken).ConfigureAwait(false); context.Add(sagaInstance); break; case SagaConsumeContextMode.Load: sagaInstance = context[instance.CorrelationId]; await sagaInstance.MarkInUse(consumeContext.CancellationToken).ConfigureAwait(false); break; default: throw new ArgumentOutOfRangeException(nameof(mode)); } return(new InMemorySagaConsumeContext <TSaga, T>(consumeContext, sagaInstance, context)); }
public InMemorySagaRepositoryContextFactory(IndexedSagaDictionary <TSaga> sagas, ISagaConsumeContextFactory <IndexedSagaDictionary <TSaga>, TSaga> factory) { _sagas = sagas; _factory = factory; }