Beispiel #1
0
            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;
            }
Beispiel #2
0
 static Dictionary <Type, CorrelationProperty[]> GetCorrelationProperties(Saga saga)
 {
     return(saga.GenerateCorrelationProperties()
            .ToLookup(p => p.MessageType)
            .ToDictionary(kvp => kvp.Key, kvp => kvp.ToArray()));
 }
Beispiel #3
0
 /// <summary>
 /// Creates a new instance of the saga's saga data
 /// </summary>
 public ISagaData CreateNewSagaData(Saga saga)
 {
     return(saga.CreateNewSagaData());
 }
Beispiel #4
0
        /// <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));
        }
Beispiel #5
0
 /// <summary>
 /// Creates a new instance of the saga's saga data
 /// </summary>
 public ISagaData CreateNewSagaData(Saga saga) => saga.CreateNewSagaData();
Beispiel #6
0
        /// <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));
        }