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); }
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); }
public string GetPrefixByAreaConfigs(AreaConfigs areaConfigs) { return((from ac in AreasByRoute where ac.Value == areaConfigs select ac.Key).FirstOrDefault()); }
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); }
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; }
public string GetPrefixByAreaConfigs(AreaConfigs areaConfigs) { return (from ac in AreasByRoute where ac.Value == areaConfigs select ac.Key).FirstOrDefault(); }