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

GetRouteParamsFromAttributes() private static method

private static GetRouteParamsFromAttributes ( ) : List
return List
        private static List<MapRouteParams> GetRouteParamsFromAttributes(params Assembly[] assemblies)
        {
            List<MapRouteParams> routeParams = new List<MapRouteParams>();

            foreach (Assembly a in assemblies)
            {
                var controllers = from t in a.GetTypes()
                                  where t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(System.Web.Mvc.Controller))
                                  select t;

                foreach (Type type in controllers)
                {
                    foreach (MethodInfo methodInfo in type.GetMethods())
                    {
                        foreach (UrlRouteAttribute routeAttrib in methodInfo.GetCustomAttributes(typeof(UrlRouteAttribute), false))
                        {
                            string controllerName = type.Name;
                            if (!controllerName.EndsWith("Controller", StringComparison.InvariantCultureIgnoreCase))
                            {
                                string errorMessage = string.Format("Invalid controller class name {0}: name must end with \"Controller\"",
                                    controllerName);

                                log.Fatal(errorMessage);
                                throw new ApplicationException(errorMessage);
                            }

                            controllerName = controllerName.Substring(0, controllerName.Length - "Controller".Length);
                            if (routeAttrib.Path.StartsWith("/") || routeAttrib.Path.Contains("?"))
                            {
                                string errorMessage = string.Format("Invalid UrlRoute attribute \"{0}\" on method {1}.{2}: Path cannot start with \"/\" or contain \"?\".",
                                    routeAttrib.Path, controllerName, methodInfo.Name);

                                log.Fatal(errorMessage);
                                throw new ApplicationException(errorMessage);
                            }

                            routeParams.Add(new MapRouteParams
                            {
                                RouteName = string.IsNullOrEmpty(routeAttrib.Name) ? null : routeAttrib.Name,
                                Path = routeAttrib.Path,
                                ControllerName = controllerName,
                                ActionName = methodInfo.Name,
                                Order = routeAttrib.Order,
                                Constraints = UrlRoutingUtility.GetConstraints(methodInfo),
                                Defaults = UrlRoutingUtility.GetDefaults(methodInfo),
                                ControllerNamespace = type.Namespace,
                            });
                        }
                    }
                }
            }

            return routeParams;
        }