PipelineAsync(IPipelineMiddleware middleware, IEnumerable <IPipelineContributor> contributors,
               IEnumerable <ContributorCall> callGraph, List <IPipelineMiddlewareFactory> middlewareFactories)
 {
     _middleware         = middleware;
     Contributors        = contributors.ToList().AsReadOnly();
     CallGraph           = callGraph;
     MiddlewareFactories = middlewareFactories;
 }
 protected void next_sets_pipeline_to(params PipelineContinuation[] states)
 {
     Next = new DelegateMiddleware(async env =>
     {
         env.PipelineData.PipelineStage.CurrentState = states[NextCallCount];
         NextCallCount++;
     });
 }
示例#3
0
        public LoggingMiddleware(IPipelineMiddleware next)
        {
            _next = next;
            AbstractContributorMiddleware contrib;
            var isContrib = (contrib = next as AbstractContributorMiddleware) != null;

            _log = isContrib ? LogContributor(next, contrib) : LogMiddleware(next);
        }
示例#4
0
 public TwoPhasedMiddleware(
     IPipelineMiddleware requestPipeline,
     IPipelineMiddleware responsePipeline,
     IPipelineMiddleware catastrophicFail,
     IPipelineMiddleware cleanup)
 {
     _requestPipeline  = requestPipeline;
     _responsePipeline = responsePipeline;
     _catastrophicFail = catastrophicFail;
     _cleanup          = cleanup;
 }
 public TwoPhasedMiddleware(
   IPipelineMiddleware requestPipeline,
   IPipelineMiddleware responsePipeline,
   IPipelineMiddleware catastrophicFail,
   IPipelineMiddleware cleanup)
 {
   _requestPipeline = requestPipeline;
   _responsePipeline = responsePipeline;
   _catastrophicFail = catastrophicFail;
   _cleanup = cleanup;
 }
 async Task InvokeSafe(IPipelineMiddleware middleware, ICommunicationContext env)
 {
   try
   {
     await middleware.Invoke(env);
   }
   catch (Exception e)
   {
     env.ServerErrors.Add(new Error {Exception = e});
     env.Abort();
   }
 }
示例#7
0
 async Task InvokeSafe(IPipelineMiddleware middleware, ICommunicationContext env)
 {
     try
     {
         await middleware.Invoke(env);
     }
     catch (Exception e)
     {
         env.ServerErrors.Add(new Error {
             Exception = e
         });
         env.Abort();
     }
 }
 protected void next_is(Func <ICommunicationContext, Task> invoke)
 {
     Next = new DelegateMiddleware(env =>
     {
         try
         {
             return(invoke(env));
         }
         finally
         {
             NextCallCount++;
         }
     });
 }
        public static IPipelineBuilder <TContext> Insert <TContext>(this IPipelineBuilder <TContext> builder,
                                                                    IPipelineMiddleware <TContext> middleware,
                                                                    int?index = null)
            where TContext : IPipelineContext
        {
            PipelineDelegate <TContext> pipelineDelegate(PipelineDelegate <TContext> next)
            {
                return(async(context) =>
                {
                    if (context.Terminated)
                    {
                        return;
                    }
                    await middleware.InvokeAsync(context);

                    await next.Invoke(context);
                });
            }

            return(builder.Insert(pipelineDelegate, index));
        }
示例#10
0
 public IPipelineMiddleware Compose(IPipelineMiddleware next)
 {
     return(new SimpleMiddleware(next));
 }
示例#11
0
 public IPipelineMiddleware Compose(IPipelineMiddleware next)
 {
     return(new LoggingMiddleware(next));
 }
示例#12
0
 public IPipelineMiddleware Compose(IPipelineMiddleware next)
 {
     return(this);
 }
 public IPipelineMiddleware Compose(IPipelineMiddleware next)
 {
     return(new YieldBeforeNextMiddleware(typeof(T).Name).Compose(next));
 }
示例#14
0
 static string LogContributor(IPipelineMiddleware next, AbstractContributorMiddleware contrib)
 {
     return($"Executing contributor {contrib.ContributorCall.ContributorTypeName}." +
            $"{contrib.ContributorCall.Action.Method.Name} ({next.GetType().Name} middleware)");
 }
示例#15
0
 static string LogMiddleware(IPipelineMiddleware next)
 {
     return($"Executing middleware {next.GetType().Name}");
 }
 public YieldingMiddleware(IPipelineMiddleware inner)
 {
     _inner = inner;
 }
示例#17
0
 public IPipelineMiddleware Compose(IPipelineMiddleware next)
 {
     _responsePipeline = next;
     return(this);
 }
 public virtual IPipelineMiddleware Compose(IPipelineMiddleware next)
 {
   Next = next;
   return this;
 }
示例#19
0
 public SimpleMiddleware(IPipelineMiddleware next)
 {
     _next = next;
 }
 public IPipelineMiddleware Compose(IPipelineMiddleware next)
 {
     this.Next = next;
     return(this);
 }
 public virtual IPipelineMiddleware Compose(IPipelineMiddleware next)
 {
     Next = next;
     return(this);
 }