示例#1
0
 public static IMiddlewarePipeline Add(this IMiddlewarePipeline pipeline, NextDelegate method)
 {
     if (pipeline == null)
     {
         throw new ArgumentNullException(nameof(pipeline));
     }
     if (method == null)
     {
         throw new ArgumentNullException(nameof(method));
     }
     pipeline.AddLast(new DelegateMiddleware(method));
     return(pipeline);
 }
示例#2
0
        public static IMiddlewarePipeline AddMvc(this IMiddlewarePipeline pipeline, IRouter router)
        {
            if (pipeline == null)
            {
                throw new ArgumentNullException(nameof(pipeline));
            }
            if (router == null)
            {
                throw new ArgumentNullException(nameof(router));
            }
            var middleware = new MvcMiddleware(router);

            pipeline.AddLast(middleware);
            return(pipeline);
        }
示例#3
0
        public static IMiddlewarePipeline AddMvc(this IMiddlewarePipeline pipeline, IServiceProvider provider)
        {
            if (pipeline == null)
            {
                throw new ArgumentNullException(nameof(pipeline));
            }
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }
            var router     = provider.GetService <IRouter>();
            var middleware = new MvcMiddleware(router);

            pipeline.AddLast(middleware);
            return(pipeline);
        }