コード例 #1
0
        public SetCorrelationIdMessageSendTopology(IMessageCorrelationId <T> messageCorrelationId)
        {
            if (messageCorrelationId == null)
            {
                throw new ArgumentNullException(nameof(messageCorrelationId));
            }

            _filter = new SetCorrelationIdFilter <T>(messageCorrelationId);
        }
        public MessageCorrelationIdEventCorrelationBuilder(SagaStateMachine <TInstance> machine, Event <TData> @event,
                                                           IMessageCorrelationId <TData> messageCorrelationId)
        {
            var configurator = new MassTransitEventCorrelationConfigurator <TInstance, TData>(machine, @event, null);

            configurator.CorrelateById(x => messageCorrelationId.TryGetCorrelationId(x.Message, out var correlationId)
                ? correlationId
                : throw new ArgumentException($"The message {TypeMetadataCache<TData>.ShortName} did not have a correlationId"));

            _configurator = configurator;
        }
コード例 #3
0
        public bool TryGetMessageCorrelationId(out IMessageCorrelationId <TMessage> messageCorrelationId)
        {
            foreach (ICorrelationIdSelector <TMessage> selector in _selectors)
            {
                if (selector.TryGetSetCorrelationId(out messageCorrelationId))
                {
                    return(true);
                }
            }

            messageCorrelationId = null;
            return(false);
        }
コード例 #4
0
        public bool TryGetSetCorrelationId(out IMessageCorrelationId <T> messageCorrelationId)
        {
            var correlatedByInterface = typeof(T).GetInterface <CorrelatedBy <Guid> >();

            if (correlatedByInterface != null)
            {
                var objectType = typeof(CorrelatedByMessageCorrelationId <>).MakeGenericType(typeof(T));
                messageCorrelationId = (IMessageCorrelationId <T>)Activator.CreateInstance(objectType);
                return(true);
            }

            messageCorrelationId = null;
            return(false);
        }
コード例 #5
0
        public bool TryGetSetCorrelationId(out IMessageCorrelationId <T> messageCorrelationId)
        {
            var propertyInfo = typeof(T).GetProperty(_propertyName);

            if (propertyInfo != null && propertyInfo.PropertyType == typeof(Guid))
            {
                messageCorrelationId = new PropertyMessageCorrelationId <T>(propertyInfo);
                return(true);
            }

            if (propertyInfo != null && propertyInfo.PropertyType == typeof(Guid?))
            {
                messageCorrelationId = new NullablePropertyMessageCorrelationId <T>(propertyInfo);
                return(true);
            }

            messageCorrelationId = null;
            return(false);
        }
コード例 #6
0
 public void SetCorrelationId(IMessageCorrelationId <TMessage> messageCorrelationId)
 {
     _selectors.Insert(0, new SetCorrelationIdSelector <TMessage>(messageCorrelationId));
 }
コード例 #7
0
 public bool TryGetSetCorrelationId(out IMessageCorrelationId <T> messageCorrelationId)
 {
     messageCorrelationId = _messageCorrelationId;
     return(true);
 }
コード例 #8
0
 public SetCorrelationIdSelector(IMessageCorrelationId <T> messageCorrelationId)
 {
     _messageCorrelationId = messageCorrelationId;
 }
コード例 #9
0
 public SetCorrelationIdFilter(IMessageCorrelationId <T> messageCorrelationId)
 {
     _messageCorrelationId = messageCorrelationId;
 }