예제 #1
0
 public void SetUp()
 {
     _routeCollection = MockRepository.GenerateMock<IRouteCollection>();
     _httpRuntime = MockRepository.GenerateMock<IHttpRuntime>();
     _httpRuntime.Stub(arg => arg.AppDomainAppVirtualPath).Return("/path");
     _urlResolver = new UrlResolver(_routeCollection, _httpRuntime);
 }
예제 #2
0
        public AspNetHttpHandler(
            IRouteCollection routes,
            ICache cache,
            IEnumerable <IResponseGenerator> responseGenerators,
            IEnumerable <IResponseHandler> responseHandlers,
            IAntiCsrfCookieManager antiCsrfCookieManager,
            IAntiCsrfNonceValidator antiCsrfNonceValidator,
            IAntiCsrfResponseGenerator antiCsrfResponseGenerator)
        {
            routes.ThrowIfNull("routes");
            cache.ThrowIfNull("cache");
            responseGenerators.ThrowIfNull("responseGenerators");
            responseHandlers.ThrowIfNull("responseHandlers");
            antiCsrfCookieManager.ThrowIfNull("antiCsrfSessionManager");
            antiCsrfNonceValidator.ThrowIfNull("antiCsrfTokenValidator");
            antiCsrfResponseGenerator.ThrowIfNull("antiCsrfResponseGenerator");

            _routes                    = routes;
            _cache                     = cache;
            _responseGenerators        = responseGenerators.ToArray();
            _responseHandlers          = responseHandlers.ToArray();
            _antiCsrfCookieManager     = antiCsrfCookieManager;
            _antiCsrfNonceValidator    = antiCsrfNonceValidator;
            _antiCsrfResponseGenerator = antiCsrfResponseGenerator;
        }
예제 #3
0
		public AspNetHttpHandler(
			IRouteCollection routes,
			ICache cache,
			IEnumerable<IResponseGenerator> responseGenerators,
			IEnumerable<IResponseHandler> responseHandlers,
			IAntiCsrfCookieManager antiCsrfCookieManager,
			IAntiCsrfNonceValidator antiCsrfNonceValidator,
			IAntiCsrfResponseGenerator antiCsrfResponseGenerator)
		{
			routes.ThrowIfNull("routes");
			cache.ThrowIfNull("cache");
			responseGenerators.ThrowIfNull("responseGenerators");
			responseHandlers.ThrowIfNull("responseHandlers");
			antiCsrfCookieManager.ThrowIfNull("antiCsrfSessionManager");
			antiCsrfNonceValidator.ThrowIfNull("antiCsrfTokenValidator");
			antiCsrfResponseGenerator.ThrowIfNull("antiCsrfResponseGenerator");

			_routes = routes;
			_cache = cache;
			_responseGenerators = responseGenerators.ToArray();
			_responseHandlers = responseHandlers.ToArray();
			_antiCsrfCookieManager = antiCsrfCookieManager;
			_antiCsrfNonceValidator = antiCsrfNonceValidator;
			_antiCsrfResponseGenerator = antiCsrfResponseGenerator;
		}
예제 #4
0
        /// <summary>
        /// 获取指定URL的功能信息
        /// </summary>
        public static IFunction GetFunction(this ControllerBase controller, string url)
        {
            url = url.StartsWith("https://") || url.StartsWith("http://")
                ? new Uri(url).AbsolutePath : !url.StartsWith("/") ? $"/{url}" : url;
            IServiceProvider    provider    = controller.HttpContext.RequestServices;
            IHttpContextFactory factory     = provider.GetService <IHttpContextFactory>();
            HttpContext         httpContext = factory.Create(controller.HttpContext.Features);

            httpContext.Request.Path   = url;
            httpContext.Request.Method = "POST";
            RouteContext     routeContext = new RouteContext(httpContext);
            IRouteCollection router       = controller.RouteData.Routers.OfType <IRouteCollection>().FirstOrDefault();

            if (router == null)
            {
                return(null);
            }
            router.RouteAsync(routeContext).Wait();
            if (routeContext.Handler == null)
            {
                return(null);
            }
            RouteValueDictionary dict       = routeContext.RouteData.Values;
            string           areaName       = dict.GetOrDefault("area")?.ToString();
            string           controllerName = dict.GetOrDefault("controller")?.ToString();
            string           actionName     = dict.GetOrDefault("action")?.ToString();
            IFunctionHandler handler        = provider.GetService <IFunctionHandler>();

            return(handler?.GetFunction(areaName, controllerName, actionName));
        }
예제 #5
0
        public UrlResolver(IRouteCollection routes, IHttpRuntime httpRuntime)
        {
            routes.ThrowIfNull("routes");
            httpRuntime.ThrowIfNull("httpRuntime");

            _routes      = new Lazy <IRouteCollection>(() => routes);
            _httpRuntime = httpRuntime;
        }
예제 #6
0
		public UrlResolver(IRouteCollection routes, IHttpRuntime httpRuntime)
		{
			routes.ThrowIfNull("routes");
			httpRuntime.ThrowIfNull("httpRuntime");

			_routes = new Lazy<IRouteCollection>(() => routes);
			_httpRuntime = httpRuntime;
		}
예제 #7
0
        public UrlResolver(IRouteCollection routes, IUrlResolverConfiguration configuration, IHttpRuntime httpRuntime)
        {
            routes.ThrowIfNull("routes");
            configuration.ThrowIfNull("configuration");
            httpRuntime.ThrowIfNull("httpRuntime");

            _routes = new Lazy<IRouteCollection>(() => routes);
            _configuration = configuration;
            _httpRuntime = httpRuntime;
        }
예제 #8
0
        public UrlResolver(IRouteCollection routes, IUrlResolverConfiguration configuration, IHttpRuntime httpRuntime)
        {
            routes.ThrowIfNull("routes");
            configuration.ThrowIfNull("configuration");
            httpRuntime.ThrowIfNull("httpRuntime");

            _routes        = new Lazy <IRouteCollection>(() => routes);
            _configuration = configuration;
            _httpRuntime   = httpRuntime;
        }
예제 #9
0
        public AspNetHttpHandler(IRouteCollection routes, ICache cache, IEnumerable <IResponseGenerator> responseGenerators, IEnumerable <IResponseHandler> responseHandlers)
        {
            routes.ThrowIfNull("routes");
            cache.ThrowIfNull("cache");
            responseGenerators.ThrowIfNull("responseGenerators");
            responseHandlers.ThrowIfNull("responseHandlers");

            _routes             = routes;
            _cache              = cache;
            _responseGenerators = responseGenerators.ToArray();
            _responseHandlers   = responseHandlers.ToArray();
        }
예제 #10
0
        public AspNetHttpHandler(IRouteCollection routes, ICache cache, IEnumerable<IResponseGenerator> responseGenerators, IEnumerable<IResponseHandler> responseHandlers)
        {
            routes.ThrowIfNull("routes");
            cache.ThrowIfNull("cache");
            responseGenerators.ThrowIfNull("responseGenerators");
            responseHandlers.ThrowIfNull("responseHandlers");

            _routes = routes;
            _responseGenerators = responseGenerators.ToArray();
            _responseHandlers = responseHandlers.ToArray();
            _cache = cache;
        }
        public static IRouteCollection MapVerb(
            this IRouteCollection collection,
            IInlineConstraintResolver inlineConstraintResolver,
            string verb,
            string template,
            Func <HttpRequest, HttpResponse, RouteData, Task> handler)
        {
            RequestDelegate requestDelegate = (httpContext) =>
            {
                return(handler(httpContext.Request, httpContext.Response, httpContext.GetRouteData()));
            };

            return(collection.MapVerb(inlineConstraintResolver, verb, template, requestDelegate));
        }
예제 #12
0
파일: UWebEngine.cs 프로젝트: UStack/UWeb
        public UWebEngine(IRouteCollection collection, IRequestGraph requestGraph, IServiceContainer serviceContainer, IPrePipelineCollection prePipelineCollection, 
            IPostPipelineCollection postPipelineCollection)
        {
            collection.ArgumentNullCheck("collection");
            requestGraph.ArgumentNullCheck("requestGraph");
            serviceContainer.ArgumentNullCheck("serviceContainer");
            prePipelineCollection.ArgumentNullCheck("prePipelineCollection");
            postPipelineCollection.ArgumentNullCheck("postPipelineCollection");

            this.collection = collection;
            this.requestGraph = requestGraph;
            this.serviceContainer = serviceContainer;
            this.prePipelineCollection = prePipelineCollection;
            this.postPipelineCollection = postPipelineCollection;
        }
예제 #13
0
        public async Task <bool> Check(string path, string method)
        {
            IRouteCollection router = RouteData.Routers.OfType <IRouteCollection>().First();

            HttpContext context = _httpContextFactory.Create(HttpContext.Features);

            context.Request.Path   = path;
            context.Request.Method = method;

            var routeContext = new RouteContext(context);
            await router.RouteAsync(routeContext);

            bool exists = routeContext.Handler != null;

            return(exists);
        }
        public static IRouteCollection MapVerb(
            this IRouteCollection collection,
            IInlineConstraintResolver inlineConstraintResolver,
            string verb,
            string template,
            RequestDelegate handler)
        {
            var route = new Route(
                new RouteHandler(handler),
                verb + template,
                template,
                defaults: null,
                constraints: new RouteValueDictionary(new { httpMethod = new HttpMethodRouteConstraint(verb) }),
                dataTokens: null,
                inlineConstraintResolver: inlineConstraintResolver);

            collection.Add(route);
            return(collection);
        }
예제 #15
0
파일: Index.cs 프로젝트: UStack/UWeb
 public Index(IRouteCollection routeCollection)
 {
     this.routeCollection = routeCollection;
 }
예제 #16
0
        public void SetUp()
        {
            routeCollection = A.Fake<IRouteCollection>();
            outputWriter = A.Fake<IOutputWriter>();
            requestGraph = A.Fake<IRequestGraph>();
            prePipelineCollection = A.Fake<IPrePipelineCollection>();
            postPipelineCollection = A.Fake<IPostPipelineCollection>();

            endpoint = A.Fake<IEndpoint>();
            request = A.Fake<IRequest>();
            route = A.Fake<IRoute>();
            requestChain = A.Fake<IRequestChain>();
            response = A.Fake<IResponse>();

            serviceContainer = A.Fake<IServiceContainer>();

            A.CallTo(() => route.Endpoint).Returns(endpoint);
            A.CallTo(() => routeCollection.Resolve(request)).Returns(route);
            A.CallTo(() => requestGraph.FindChainFor(endpoint)).Returns(requestChain);
            A.CallTo(() => outputWriter.CreateResponse()).Returns(response);

            engine = new UWebEngine(routeCollection, requestGraph, serviceContainer, prePipelineCollection, postPipelineCollection);
        }
        public RoutingDiagnosticConfiguration(IRouteCollection routes)
        {
            routes.ThrowIfNull("routes");

            _routes = new Lazy <IRouteCollection>(() => routes);
        }
예제 #18
0
 public void SetUp()
 {
     _routeCollection = MockRepository.GenerateMock<IRouteCollection>();
     _httpRuntime = MockRepository.GenerateMock<IHttpRuntime>();
     _urlResolver = new UrlResolver(_routeCollection, _httpRuntime);
 }
예제 #19
0
 public Navigator(IServiceProvider services, IRouteCollection routes)
 {
     this.Services = services;
     this.Routes   = routes;
 }
예제 #20
0
 public void SetUp()
 {
     routeCollection = A.Fake<IRouteCollection>();
     route = A.Fake<IRoute>();
     urlBuilder = new DefaultUrlBuilder(routeCollection);
 }
        public RoutingDiagnosticConfiguration(IRouteCollection routes)
        {
            routes.ThrowIfNull("routes");

            _routes = new Lazy<IRouteCollection>(() => routes);
        }