Exemple #1
0
        public static void AliasRouteEx(this RouteCollection routes, string alias, string url, object aliasConstraints, Func <RouteData, RouteData, RouteData> routeDataJoiner)
        {
            if (routes == null)
            {
                throw new ArgumentNullException("routes");
            }
            if (alias == null)
            {
                throw new ArgumentNullException("alias");
            }
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url");
            }
            if (routeDataJoiner == null)
            {
                throw new ArgumentNullException("routeDataJoiner");
            }
#if CLR4
            EnsureRouteCollectionReaderWriterLock(routes);
#endif
            routes.Add(new AliasRouteExInternal(alias, () => routes.FindRouteDataByUrl(HttpContext.Current, url), routeDataJoiner)
            {
                Constraints = new RouteValueDictionary(aliasConstraints)
            });
        }