/// <summary> /// Get Routing via Controllers /// </summary> /// <param name="assembly">Assembly</param> /// <returns>Route Collection</returns> public virtual RouteCollection GetControllers(Assembly assembly) { var routes = new RouteCollection(); foreach (var type in assembly.GetTypes().Where(cls => cls.GetInterfaces().Contains(typeof(IRoutableController)))) { var className = type.Name.EndsWith("Controller") ? type.Name.Replace("Controller", string.Empty) : type.Name; routes.Merge(this.GetMethods(type, className)); } return routes; }
/// <summary> /// Get Attributes /// </summary> /// <param name="assembly">Assembly</param> /// <returns>Route Collection</returns> public virtual RouteCollection GetAttributes(Assembly assembly) { var routes = new RouteCollection(); foreach (var type in assembly.GetTypes()) { var attribute = type.GetCustomAttribute<RouteAliasAttribute>(false); if (null != attribute) { routes.Merge(this.GetMethods(type, attribute.Name)); } } return routes; }