예제 #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
파일: Chain.cs 프로젝트: sonbua/async-dolls
 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);
 }