示例#1
0
        public string ParseArea(string url, out AreaConfigs configs)
        {
            configs = GetAreaConfigsByPrefix(url);
            if (configs != null)
            {
                return("/");
            }

            var pos = url.LastIndexOf('/');

            if (pos > 0)
            {
                while (pos > 0 && (configs = GetAreaConfigsByPrefix(url.Substring(0, pos))) == null)
                {
                    pos = url.LastIndexOf('/', pos - 1);
                }
            }
            if (configs != null)
            {
                return(url.Substring(pos));
            }

            configs = GetAreaConfigsByPrefix("/");
            return(url);
        }
示例#2
0
        public void RegisterArea(string prefix, AreaConfigs configs)
        {
            if (prefix != null)
            {
                if (!prefix.StartsWith("/"))
                {
                    throw new ArgumentException("URL prefix for area has to start with a /", "prefix");
                }

                if (prefix.Length > 1)
                {
                    prefix = prefix.TrimEnd(new[] { ' ', '/' });
                }

                AreasByRoute.AddOrUpdate(prefix, s => configs, (s, s1) => configs);
            }

            AreasByName.AddOrUpdate(configs.AreaName.ToLower(CultureInfo.InvariantCulture), s => configs, (s, s1) => configs);
        }
示例#3
0
 public string GetPrefixByAreaConfigs(AreaConfigs areaConfigs)
 {
     return((from ac in AreasByRoute where ac.Value == areaConfigs select ac.Key).FirstOrDefault());
 }
示例#4
0
        public void RegisterArea(string prefix, AreaConfigs configs)
        {
            if (prefix != null)
            {
                if (!prefix.StartsWith("/"))
                    throw new ArgumentException("URL prefix for area has to start with a /", "prefix");

                if (prefix.Length > 1)
                    prefix = prefix.TrimEnd(new[] {' ', '/'});

                AreasByRoute.AddOrUpdate(prefix, s => configs, (s, s1) => configs);
            }

            AreasByName.AddOrUpdate(configs.AreaName.ToLower(CultureInfo.InvariantCulture), s => configs, (s, s1) => configs);
        }
示例#5
0
        public string ParseArea(string url, out AreaConfigs configs)
        {
            configs = GetAreaConfigsByPrefix(url);
            if (configs != null) return "/";

            var pos = url.LastIndexOf('/');
            if (pos > 0)
            {
                while (pos > 0 && (configs = GetAreaConfigsByPrefix(url.Substring(0, pos))) == null)
                {
                    pos = url.LastIndexOf('/', pos - 1);
                }
            }
            if (configs != null) return url.Substring(pos);

            configs = GetAreaConfigsByPrefix("/");
            return url;
        }
示例#6
0
 public string GetPrefixByAreaConfigs(AreaConfigs areaConfigs)
 {
     return (from ac in AreasByRoute where ac.Value == areaConfigs select ac.Key).FirstOrDefault();
 }