Пример #1
0
        public MiddlewareNode <T> AddMiddleware <T>(BehaviorCategory category = BehaviorCategory.Process) where T : class, IOwinMiddleware
        {
            var node = new MiddlewareNode <T>();

            AddMiddleware(node);

            return(node);
        }
Пример #2
0
 public void SetNext(MiddlewareNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException(nameof(node));
     }
     this.Next = new NextDelegate(node);
 }
Пример #3
0
        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);
        }
Пример #4
0
        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();
        }
Пример #5
0
        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();
        }
Пример #6
0
        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);
        }
Пример #7
0
 public void AddMiddleware(MiddlewareNode node)
 {
     Middleware.AddToEnd(node);
 }
Пример #8
0
 public NextDelegate(MiddlewareNode node)
 {
     this.Node = node ?? throw new ArgumentNullException(nameof(node));
 }