예제 #1
0
        Task InnerInvoke(TransportMessage transportMessage, int currentIndex = 0)
        {
            if (currentIndex == linkElements.Count)
            {
                return Task.CompletedTask;
            }

            ILinkElement step = linkElements[currentIndex];

            return step.Invoke(transportMessage, () => InnerInvoke(transportMessage, currentIndex + 1));
        }
예제 #2
0
        public TransportMessage(TransportMessage transportMessage)
        {
            Headers = new Dictionary<string, string>
            {
                {HeaderKeys.MessageId, transportMessage.Id},
                {HeaderKeys.CorrelationId, transportMessage.CorrelationId},
                {HeaderKeys.MessageType, transportMessage.MessageType},
                {HeaderKeys.ReplyTo, transportMessage.ReplyTo?.ToString() }
            };

            var stream = new MemoryStream();
            transportMessage.Body.Position = 0;
            transportMessage.Body.CopyTo(stream);
            stream.Position = 0;
            SetBody(stream);

            foreach (var pair in transportMessage.Headers)
            {
                if (!Headers.ContainsKey(pair.Key))
                {
                    Headers.Add(pair.Key, pair.Value);
                }
            }
        }
예제 #3
0
 public Task Invoke(TransportMessage transportMessage)
 {
     return InnerInvoke(transportMessage);
 }
예제 #4
0
 public Task Invoke(TransportMessage transportMessage, Func<Task> next)
 {
     countdown.Signal();
     return next();
 }
예제 #5
0
 public Task Invoke(TransportMessage transportMessage, Func<Task> next)
 {
     transportMessage.Id.Output();
     return next();
 }
예제 #6
0
 public async Task Invoke(TransportMessage transportMessage, Func<Task> next)
 {
     await Task.Delay(1000).ConfigureAwait(false);
     await next().ConfigureAwait(false);
 }
예제 #7
0
 static Task Connector(ChainFactory factory, TransportMessage transportMessage)
 {
     var pipeline = factory.Create();
     return pipeline.Invoke(transportMessage);
 }