Sage.Routing.UrlRoutingUtility.RegisterRoutesToMethodsWithAttributes C# (CSharp) Method

RegisterRoutesToMethodsWithAttributes() static private method

Uses reflection to enumerate through Controller classes in the assembly and registers a route for each method declaring a UrlRouteAttribute.
static private RegisterRoutesToMethodsWithAttributes ( Assembly assemblies ) : void
assemblies System.Reflection.Assembly Assemblies that contain the methods to register.
return void
        internal static void RegisterRoutesToMethodsWithAttributes(Assembly[] assemblies)
        {
            List<MapRouteParams> routeParams = UrlRoutingUtility.GetRouteParamsFromAttributes(
                Project.RelevantAssemblies.ToArray());

            routeParams.Sort((a, b) => a.Order.CompareTo(b.Order));
            foreach (MapRouteParams rd in routeParams)
            {
                log.DebugFormat("Automatically registering route '{0}' for controller '{1}Controller.{2}' (Priority = {3}, Name = {4})",
                    rd.Path, rd.ControllerName, rd.ActionName, rd.Order, rd.RouteName ?? "<null>");

                rd.Defaults["controller"] = rd.ControllerName;
                rd.Defaults["action"] = rd.ActionName;

                string name = rd.RouteName;
                if (string.IsNullOrEmpty(name))
                    name = string.Concat(rd.ControllerName, ".", rd.ActionName);

                UrlRoutingUtility.MapRoute(name, rd.Path, rd.Defaults, rd.Constraints, new[] { rd.ControllerNamespace });
            }
        }