public IList <Route> MapHttpRoute(string moduleFolderName, string routeName, string url, object defaults, object constraints, string[] namespaces) { if (namespaces == null || namespaces.Length == 0 || String.IsNullOrEmpty(namespaces[0])) { throw new ArgumentException(Localization.GetExceptionMessage("ArgumentCannotBeNullOrEmpty", "The argument '{0}' cannot be null or empty.", "namespaces")); } Requires.NotNullOrEmpty("moduleFolderName", moduleFolderName); url = url.Trim(new[] { '/', '\\' }); IEnumerable <int> prefixCounts = _portalAliasRouteManager.GetRoutePrefixCounts(); var routes = new List <Route>(); foreach (int count in prefixCounts) { string fullRouteName = _portalAliasRouteManager.GetRouteName(moduleFolderName, routeName, count); string routeUrl = _portalAliasRouteManager.GetRouteUrl(moduleFolderName, url, count); Route route = MapHttpRouteWithNamespace(fullRouteName, routeUrl, defaults, constraints, namespaces); routes.Add(route); Logger.Trace("Mapping route: " + fullRouteName + " @ " + routeUrl); } return(routes); }
public IList <Route> MapHttpRoute(string moduleFolderName, string routeName, string url, object defaults, object constraints, string[] namespaces) { if (namespaces == null || namespaces.Length == 0 || String.IsNullOrEmpty(namespaces[0])) { throw new ArgumentException(Localization.GetExceptionMessage("ArgumentCannotBeNullOrEmpty", "The argument '{0}' cannot be null or empty.", "namespaces")); } Requires.NotNullOrEmpty("moduleFolderName", moduleFolderName); url = url.Trim('/', '\\'); IEnumerable <int> prefixCounts = _portalAliasRouteManager.GetRoutePrefixCounts(); var routes = new List <Route>(); foreach (int count in prefixCounts) { string fullRouteName = _portalAliasRouteManager.GetRouteName(moduleFolderName, routeName, count); string routeUrl = _portalAliasRouteManager.GetRouteUrl(moduleFolderName, url, count); Route route = MapHttpRouteWithNamespace(fullRouteName, routeUrl, defaults, constraints, namespaces); routes.Add(route); if (Logger.IsTraceEnabled) { Logger.Trace("Mapping route: " + fullRouteName + " @ " + routeUrl); } //compatible with old service path: DesktopModules/{namespace}/API/{controller}/{action}. var oldRouteName = $"{fullRouteName}-old"; var oldRouteUrl = PortalAliasRouteManager.GetOldRouteUrl(moduleFolderName, url, count); var oldRoute = MapHttpRouteWithNamespace(oldRouteName, oldRouteUrl, defaults, constraints, namespaces); routes.Add(oldRoute); if (Logger.IsTraceEnabled) { Logger.Trace("Mapping route: " + oldRouteName + " @ " + oldRouteUrl); } } return(routes); }