public MiddlewareNode <T> AddMiddleware <T>(BehaviorCategory category = BehaviorCategory.Process) where T : class, IOwinMiddleware { var node = new MiddlewareNode <T>(); AddMiddleware(node); return(node); }
public void SetNext(MiddlewareNode node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } this.Next = new NextDelegate(node); }
public MiddlewareNode AddMiddleware <T>(params object[] args) where T : class { var description = "{0} - {1}".ToFormat(typeof(T).FullName, args.Select(x => (x ?? string.Empty).ToString()).Join(", ")); var node = new MiddlewareNode(x => x.Use(typeof(T), args)).Description(description); Middleware.AddToEnd(node); return(node); }
public void disposes_any_disposable_middleware_on_shutdown() { MiddlewareNode <SpecialDisposableMiddleware> node = null; using (var server = serverFor(x => { node = x.AddMiddleware <SpecialDisposableMiddleware>(); })) { server.Scenario(_ => { _.Get.Action <MiddleWareInterceptedEndpoint>(x => x.get_middleware_result()); _.ContentShouldContain("I'm okay"); }); } node.Middleware.IWasDisposed.ShouldBeTrue(); }
public void disposes_any_disposable_middleware_on_shutdown() { MiddlewareNode <SpecialDisposableMiddleware> node = null; using (var server = serverFor(x => { node = x.AddMiddleware <SpecialDisposableMiddleware>(); })) { server.Endpoints.Get <MiddleWareInterceptedEndpoint>(x => x.get_middleware_result()) .ReadAsText().ShouldContain("I'm okay"); } node.Middleware.IWasDisposed.ShouldBeTrue(); }
public IMiddlewarePipeline AddLast(IMiddleware middleware) { if (middleware == null) { throw new ArgumentNullException(nameof(middleware)); } var node = new MiddlewareNode(middleware); if (this.first == null) { this.first = node; } else { this.last.SetNext(node); } this.last = node; return(this); }
public void AddMiddleware(MiddlewareNode node) { Middleware.AddToEnd(node); }
public NextDelegate(MiddlewareNode node) { this.Node = node ?? throw new ArgumentNullException(nameof(node)); }