private SagaContext(SagaId sagaId, string originator, IEnumerable <ISagaContextMetadata> metadata) { SagaId = sagaId; Originator = originator; var areMetadataKeysUnique = metadata.GroupBy(m => m.Key).All(g => g.Count() is 1); if (!areMetadataKeysUnique) { throw new ChronicleException("Metadata keys are not unique"); } Metadata = metadata.ToList().AsReadOnly(); }
public virtual void Initialize(SagaId id, SagaStates state) => (Id, State) = (id, state);
public static ISagaContext Create(SagaId sagaId, string originator, IEnumerable <ISagaContextMetadata> metadata) => new SagaContext(sagaId, originator, metadata);