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++; }); }
public LoggingMiddleware(IPipelineMiddleware next) { _next = next; AbstractContributorMiddleware contrib; var isContrib = (contrib = next as AbstractContributorMiddleware) != null; _log = isContrib ? LogContributor(next, contrib) : LogMiddleware(next); }
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(); } }
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)); }
public IPipelineMiddleware Compose(IPipelineMiddleware next) { return(new SimpleMiddleware(next)); }
public IPipelineMiddleware Compose(IPipelineMiddleware next) { return(new LoggingMiddleware(next)); }
public IPipelineMiddleware Compose(IPipelineMiddleware next) { return(this); }
public IPipelineMiddleware Compose(IPipelineMiddleware next) { return(new YieldBeforeNextMiddleware(typeof(T).Name).Compose(next)); }
static string LogContributor(IPipelineMiddleware next, AbstractContributorMiddleware contrib) { return($"Executing contributor {contrib.ContributorCall.ContributorTypeName}." + $"{contrib.ContributorCall.Action.Method.Name} ({next.GetType().Name} middleware)"); }
static string LogMiddleware(IPipelineMiddleware next) { return($"Executing middleware {next.GetType().Name}"); }
public YieldingMiddleware(IPipelineMiddleware inner) { _inner = inner; }
public IPipelineMiddleware Compose(IPipelineMiddleware next) { _responsePipeline = next; return(this); }
public virtual IPipelineMiddleware Compose(IPipelineMiddleware next) { Next = next; return this; }
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); }