示例#1
0
 public Task<Continuation> Invoke(IncomingContext context)
 {
     return new Continuation
     {
         After = () => Task.Delay(10)
     };
 }
示例#2
0
        public async Task<ExceptionDispatchInfo> InnerInvoke(IncomingContext context)
        {
            var continuations = new Stack<Continuation>();
            ExceptionDispatchInfo exception = null;
            foreach (var element in executingElements)
            {
                var continuation = Continuation.Empty;
                try
                {
                    continuation = await element.Invoke(context).ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    exception = ExceptionDispatchInfo.Capture(e);
                    break;
                }
                finally
                {
                    continuations.Push(continuation);
                }
            }

            foreach (var continuation in continuations)
            {
                if (exception == null)
                {
                    try
                    {
                        await continuation.After().ConfigureAwait(false);
                    }
                    catch (Exception e)
                    {
                        exception = ExceptionDispatchInfo.Capture(e);
                    }
                }
                else
                {
                    try
                    {
                        if (continuation.Catch != null)
                        {
                            exception = await continuation.Catch(exception).ConfigureAwait(false);
                        }
                    }
                    catch (Exception e)
                    {
                        exception = ExceptionDispatchInfo.Capture(e);
                    }
                }

                await continuation.Finally().ConfigureAwait(false);
            }

            return exception;
        }
示例#3
0
 public Task <Continuation> Invoke(IncomingContext context)
 {
     return(new Continuation
     {
         Catch = async info =>
         {
             info.SourceException.StackTrace.Output();
             countdown.Signal();
             return null;
         }
     });
 }
示例#4
0
 public Task Invoke(IncomingContext context)
 {
     return InnerInvoke(context);
 }
示例#5
0
            public async Task<Continuation> Invoke(IncomingContext context)
            {
                await Task.Delay(10).ConfigureAwait(false);

                throw new InvalidOperationException(nameof(ThrowException));
            }
示例#6
0
            public async Task<Continuation> Invoke(IncomingContext context)
            {
                await Task.Delay(10).ConfigureAwait(false);

                return Continuation.Empty;
            }
示例#7
0
 static Task Connector(ChainFactory factory, TransportMessage message)
 {
     var pipeline = factory.Create();
     var context = new IncomingContext(message);
     return pipeline.Invoke(context);
 }
示例#8
0
 public Task<Continuation> Invoke(IncomingContext context)
 {
     return new Continuation
     {
         Catch = async info =>
         {
             info.SourceException.StackTrace.Output();
             countdown.Signal();
             return null;
         }
     };
 }
示例#9
0
            public async Task<Continuation> Invoke(IncomingContext context)
            {
                var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
                await Task.Delay(10).ConfigureAwait(false);

                return new Continuation
                {
                    After = () => { scope.Complete(); return Task.CompletedTask; },
                    Finally = () => { scope.Dispose(); return Task.CompletedTask; }
                };
            }
示例#10
0
 public Task<Continuation> Invoke(IncomingContext context)
 {
     return Continuation.Empty;
 }
示例#11
0
 public Task Invoke(IncomingContext context)
 {
     return(InnerInvoke(context));
 }
示例#12
0
            public async Task <Continuation> Invoke(IncomingContext context)
            {
                await Task.Delay(10).ConfigureAwait(false);

                throw new InvalidOperationException(nameof(ThrowException));
            }
示例#13
0
            public async Task <Continuation> Invoke(IncomingContext context)
            {
                await Task.Delay(10).ConfigureAwait(false);

                return(Continuation.Empty);
            }
示例#14
0
 public Task <Continuation> Invoke(IncomingContext context)
 {
     return(Continuation.Empty);
 }