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)); }
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); } } }
public Task Invoke(TransportMessage transportMessage) { return InnerInvoke(transportMessage); }
public Task Invoke(TransportMessage transportMessage, Func<Task> next) { countdown.Signal(); return next(); }
public Task Invoke(TransportMessage transportMessage, Func<Task> next) { transportMessage.Id.Output(); return next(); }
public async Task Invoke(TransportMessage transportMessage, Func<Task> next) { await Task.Delay(1000).ConfigureAwait(false); await next().ConfigureAwait(false); }
static Task Connector(ChainFactory factory, TransportMessage transportMessage) { var pipeline = factory.Create(); return pipeline.Invoke(transportMessage); }