public RelevantSagaInfo(ISagaData sagaData, IEnumerable <CorrelationProperty> correlationProperties, Saga saga) { SagaData = sagaData; // only keep necessary correlation properties, i.e. CorrelationProperties = correlationProperties .GroupBy(p => p.PropertyName) .Select(g => g.First()) .ToList(); Saga = saga; }
static Dictionary <Type, CorrelationProperty[]> GetCorrelationProperties(Saga saga) { return(saga.GenerateCorrelationProperties() .ToLookup(p => p.MessageType) .ToDictionary(kvp => kvp.Key, kvp => kvp.ToArray())); }
/// <summary> /// Creates a new instance of the saga's saga data /// </summary> public ISagaData CreateNewSagaData(Saga saga) { return(saga.CreateNewSagaData()); }
/// <summary> /// Gets (most likely from a cache) the set of correlation properties relevant for the given saga handler. /// </summary> public SagaDataCorrelationProperties GetCorrelationProperties(object message, Saga saga) { var sagaType = saga.GetType(); var sagaDataType = saga.GetSagaDataType(); var key = $"{sagaType.FullName}/{sagaDataType.FullName}"; var correlationPropertiesForThisSagaDataType = _cachedCorrelationProperties .GetOrAdd(key, _ => GetCorrelationProperties(saga)); return(new SagaDataCorrelationProperties(correlationPropertiesForThisSagaDataType, sagaDataType)); }
/// <summary> /// Creates a new instance of the saga's saga data /// </summary> public ISagaData CreateNewSagaData(Saga saga) => saga.CreateNewSagaData();
/// <summary> /// Gets (most likely from a cache) the set of correlation properties relevant for the given saga handler. /// </summary> public SagaDataCorrelationProperties GetCorrelationProperties(object message, Saga saga) { var sagaDataType = saga.GetSagaDataType(); var correlationPropertiesForThisSagaDataType = _cachedCorrelationProperties .GetOrAdd(sagaDataType, type => GetCorrelationProperties(saga)); return(new SagaDataCorrelationProperties(correlationPropertiesForThisSagaDataType, sagaDataType)); }