Ejemplo n.º 1
0
        /// <summary>
        /// Gets the appropriate <see cref="VirtualPathData"/> for
        /// the provided <paramref name="values"/>,
        /// or <value>null</value>, if no matching route found.
        /// </summary>
        /// <param name="context">The context of the current request.</param>
        /// <param name="values">The <see cref="ValueDictionary"/>
        /// containing the route parameter values.</param>
        public virtual VirtualPathData GetVirtualPath(RequestContext context, ValueDictionary values)
        {
            Precondition.Require(context, () => Error.ArgumentNull("context"));
            Precondition.Require(values, () => Error.ArgumentNull("values"));

            using (GetReadLock())
            {
                foreach (RouteBase route in _nonIndexedRoutes)
                {
                    VirtualPathData vp = route.GetVirtualPath(context, values, Variables);
                    if (vp != null)
                    {
                        return(vp);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the <see cref="VirtualPathData"/> for
        /// the current instance.
        /// </summary>
        /// <param name="values">The <see cref="ValueDictionary"/>
        /// containing the route parameter values.</param>
        /// <param name="variables">The <see cref="ValueDictionary"/>
        /// containing the route variable values.</param>
        public override VirtualPathData GetVirtualPath(RequestContext context,
                                                       ValueDictionary values, ValueDictionary variables)
        {
            Precondition.Require(context, () => Error.ArgumentNull("context"));
            HttpContextBase httpContext = context.Context;
            HttpRequestBase request     = httpContext.Request;

            BoundUrl url = _parsedRoute.Bind(context.RouteData.Values, values, variables, Defaults);

            if (url == null)
            {
                return(null);
            }

            if (!MatchConstraints(httpContext, url.Values, RouteDirection.UrlGeneration))
            {
                return(null);
            }

            string appRelativePath = url.Url;
            string applicationPath = GetApplicationPath(httpContext);
            string scheme          = DetermineUriScheme(httpContext, SecureConnection);

            string virtualPath = (_parsedRoute.IsAppRelative)
                                ? httpContext.Response.ApplyAppPathModifier(String.Concat(applicationPath, appRelativePath))
                                : appRelativePath;

            string absolutePath = (_parsedRoute.IsRelative)
                                ? String.Concat(scheme, Uri.SchemeDelimiter, request.Url.Authority, virtualPath)
                                : String.Concat(scheme, Uri.SchemeDelimiter, virtualPath);

            VirtualPathData data = new VirtualPathData(this, absolutePath);

            if (_tokens != null)
            {
                foreach (KeyValuePair <string, object> kvp in _tokens)
                {
                    data.Tokens[kvp.Key] = kvp.Value;
                }
            }
            return(data);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the <see cref="VirtualPathData"/> for 
        /// the current instance.
        /// </summary>
        /// <param name="values">The <see cref="ValueDictionary"/> 
        /// containing the route parameter values.</param>
		/// <param name="variables">The <see cref="ValueDictionary"/> 
		/// containing the route variable values.</param>
        public override VirtualPathData GetVirtualPath(RequestContext context,
			ValueDictionary values, ValueDictionary variables)
        {
            Precondition.Require(context, () => Error.ArgumentNull("context"));
            HttpContextBase httpContext = context.Context;
            HttpRequestBase request = httpContext.Request;

            BoundUrl url = _parsedRoute.Bind(context.RouteData.Values, values, variables, Defaults);
            if (url == null)
                return null;
            
            if (!MatchConstraints(httpContext, url.Values, RouteDirection.UrlGeneration))
                return null;

            string appRelativePath = url.Url;
            string applicationPath = GetApplicationPath(httpContext);
			string scheme = DetermineUriScheme(httpContext, SecureConnection);

            string virtualPath = (_parsedRoute.IsAppRelative) 
				? httpContext.Response.ApplyAppPathModifier(String.Concat(applicationPath, appRelativePath)) 
				: appRelativePath;

            string absolutePath = (_parsedRoute.IsRelative) 
				? String.Concat(scheme, Uri.SchemeDelimiter, request.Url.Authority, virtualPath) 
				: String.Concat(scheme, Uri.SchemeDelimiter, virtualPath);

            VirtualPathData data = new VirtualPathData(this, absolutePath);

			if (_tokens != null)
			{
				foreach (KeyValuePair<string, object> kvp in _tokens)
					data.Tokens[kvp.Key] = kvp.Value;
			}
            return data;
        }