public void Remove(RouteConfigElement url) { if (BaseIndexOf(url) >= 0) { BaseRemove(url.Name); } }
/// <summary> /// Gets the instance of route handler. /// </summary> /// <param name="route">The route.</param> /// <returns></returns> private static IRouteHandler GetInstanceOfRouteHandler(RouteConfigElement route) { IRouteHandler routeHandler; if (string.IsNullOrEmpty(route.RouteHandlerType)) { routeHandler = new MvcRouteHandler(); } else { try { Type routeHandlerType = Type.GetType(route.RouteHandlerType); routeHandler = Activator.CreateInstance(routeHandlerType) as IRouteHandler; } catch (Exception e) { throw new ApplicationException( string.Format("Can't create an instance of IRouteHandler {0}", route.RouteHandlerType), e); } } return(routeHandler); }
public static void RegisterRoutes(RouteCollection routes, string routeFile) { lock (routes) { RouteTableSection routesTableSection = GetRouteTableSection(routeFile); if (routesTableSection != null) { //ignore route if (routesTableSection.Ignores.Count > 0) { foreach (ConfigurationElement item in routesTableSection.Ignores) { var ignore = new IgnoreRouteInternal(((IgnoreRouteElement)item).Url) { Constraints = GetRouteValueDictionary(((IgnoreRouteElement)item).Constraints.Attributes) }; routes.Add(ignore); } } if (routesTableSection.Routes.Count > 0) { for (int routeIndex = 0; routeIndex < routesTableSection.Routes.Count; routeIndex++) { RouteConfigElement route = routesTableSection.Routes[routeIndex] as RouteConfigElement; if (routes[route.Name] == null) { if (string.IsNullOrEmpty(route.RouteType)) { routes.Add(route.Name, new Route( route.Url, GetDefaults(route), GetConstraints(route), GetDataTokens(route), GetInstanceOfRouteHandler(route))); } else { var customRoute = (RouteBase)Activator.CreateInstance(Type.GetType(route.RouteType), route.Url, GetDefaults(route), GetConstraints(route), GetDataTokens(route), GetInstanceOfRouteHandler(route)); routes.Add(route.Name, customRoute); } } } } } } }
/// <summary> /// Gets the data tokens. /// </summary> /// <param name="route">The route.</param> /// <returns></returns> private static RouteValueDictionary GetDataTokens(RouteConfigElement route) { return(GetRouteValueDictionary(route.DataTokens.Attributes)); }
/// <summary> /// Gets the defaults. /// </summary> /// <param name="route">The route.</param> /// <returns></returns> private static RouteValueDictionary GetDefaults(RouteConfigElement route) { return(GetRouteValueDictionary(route.Defaults.Attributes)); }
/// <summary> /// Gets the constraints. /// </summary> /// <param name="route">The route.</param> /// <returns></returns> private static RouteValueDictionary GetConstraints(RouteConfigElement route) { return(GetRouteValueDictionary(route.Constraints.Attributes)); }
public void Add(RouteConfigElement url) { BaseAdd(url); }
public int IndexOf(RouteConfigElement url) { return(BaseIndexOf(url)); }
/// <summary> /// Gets the constraints. /// </summary> /// <param name="route">The route.</param> /// <returns></returns> private static RouteValueDictionary GetConstraints(RouteConfigElement route) { return GetRouteValueDictionary(route.Constraints.Attributes); }
/// <summary> /// Gets the data tokens. /// </summary> /// <param name="route">The route.</param> /// <returns></returns> private static RouteValueDictionary GetDataTokens(RouteConfigElement route) { return GetRouteValueDictionary(route.DataTokens.Attributes); }
/// <summary> /// Gets the instance of route handler. /// </summary> /// <param name="route">The route.</param> /// <returns></returns> private static IRouteHandler GetInstanceOfRouteHandler(RouteConfigElement route) { IRouteHandler routeHandler; if (string.IsNullOrEmpty(route.RouteHandlerType)) routeHandler = new MvcRouteHandler(); else { try { Type routeHandlerType = Type.GetType(route.RouteHandlerType); routeHandler = Activator.CreateInstance(routeHandlerType) as IRouteHandler; } catch (Exception e) { throw new ApplicationException( string.Format("Can't create an instance of IRouteHandler {0}", route.RouteHandlerType), e); } } return routeHandler; }
/// <summary> /// Gets the defaults. /// </summary> /// <param name="route">The route.</param> /// <returns></returns> private static RouteValueDictionary GetDefaults(RouteConfigElement route) { return GetRouteValueDictionary(route.Defaults.Attributes); }
public void Remove(RouteConfigElement url) { if (BaseIndexOf(url) >= 0) BaseRemove(url.Name); }
public int IndexOf(RouteConfigElement url) { return BaseIndexOf(url); }