public void SetUp() { _routeCollection = MockRepository.GenerateMock<IRouteCollection>(); _httpRuntime = MockRepository.GenerateMock<IHttpRuntime>(); _httpRuntime.Stub(arg => arg.AppDomainAppVirtualPath).Return("/path"); _urlResolver = new UrlResolver(_routeCollection, _httpRuntime); }
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; }
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; }
/// <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)); }
public UrlResolver(IRouteCollection routes, IHttpRuntime httpRuntime) { routes.ThrowIfNull("routes"); httpRuntime.ThrowIfNull("httpRuntime"); _routes = new Lazy <IRouteCollection>(() => routes); _httpRuntime = httpRuntime; }
public UrlResolver(IRouteCollection routes, IHttpRuntime httpRuntime) { routes.ThrowIfNull("routes"); httpRuntime.ThrowIfNull("httpRuntime"); _routes = new Lazy<IRouteCollection>(() => routes); _httpRuntime = httpRuntime; }
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; }
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; }
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(); }
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)); }
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; }
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); }
public Index(IRouteCollection routeCollection) { this.routeCollection = routeCollection; }
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); }
public void SetUp() { _routeCollection = MockRepository.GenerateMock<IRouteCollection>(); _httpRuntime = MockRepository.GenerateMock<IHttpRuntime>(); _urlResolver = new UrlResolver(_routeCollection, _httpRuntime); }
public Navigator(IServiceProvider services, IRouteCollection routes) { this.Services = services; this.Routes = routes; }
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); }