private AbsolutPathData ParameterSubdomain(VirtualPathContext context, string subdomainParameter)
        {
            var hostBuilder = BuildUrl(context, context.Values[subdomainParameter].ToString());

            //we have to remove our subdomain so it will not be added as query string while using GetVirtualPath method
            var values = new RouteValueDictionary(context.Values);

            values.Remove(ParameterNameFrom(Subdomain));

            var path = base.GetVirtualPath(new VirtualPathContext(context.HttpContext, context.AmbientValues, values));

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

            return(new AbsolutPathData(this, path.VirtualPath, hostBuilder.ToString()));
        }
Пример #2
0
        public override VirtualPathData GetVirtualPath(VirtualPathContext context)
        {
            if (Subdomain == null)
            {
                //if route is without subdomain and we are on host without subdomain use base method
                //we don't need whole URL for such case
                if (GetHostname(context.HttpContext.Request.Host.Value) == null)
                {
                    return(base.GetVirtualPath(context));
                }

                return(GetVirtualPath(context, context.Values, BuildUrl(context)));
            }

            var subdomainParameter = IsParameterName(Subdomain) ? ParameterNameFrom(Subdomain) : Subdomain;

            var containsSubdomainParameter = context.Values.ContainsKey(subdomainParameter);

            var defaultsContainsSubdomain = this.Defaults.ContainsKey(subdomainParameter);

            if (IsParameterName(Subdomain))
            {
                var sParameter = ParameterNameFrom(Subdomain);
                if (context.Values.ContainsKey(sParameter))
                {
                    return(ParameterSubdomain(context, context.Values[subdomainParameter].ToString()));
                }
                else if (this.Defaults.ContainsKey(sParameter))
                {
                    return(ParameterSubdomain(context, this.Defaults[sParameter].ToString()));
                }
            }
            else
            {
                if (!IsParameterName(Subdomain))
                {
                    return(StaticSubdomain(context, subdomainParameter));
                }
            }

            return(null);
        }
Пример #3
0
 protected abstract VirtualPathData OnVirtualPathGenerated(VirtualPathContext context);
Пример #4
0
 public VirtualPathData GetVirtualPath(VirtualPathContext context)
 {
     // Nothing to do.
     return(null);
 }
Пример #5
0
 protected override VirtualPathData?OnVirtualPathGenerated(VirtualPathContext context)
 {
     return(_target.GetVirtualPath(context));
 }
Пример #6
0
 public VirtualPathData GetVirtualPath(VirtualPathContext context)
 {
     return(new VirtualPathData(this, ""));
 }
Пример #7
0
 public VirtualPathData GetVirtualPath(VirtualPathContext context)
 {
     return(null);
 }
Пример #8
0
        private AbsolutPathData StaticSubdomain(VirtualPathContext context, string subdomainParameter)
        {
            var hostBuilder = BuilSubdomaindUrl(context, subdomainParameter);

            return(GetVirtualPath(context, context.Values, hostBuilder));
        }