public ActionResult Index() { var model = new RouteDebugViewModel { RouteInfos = new List<RouteInfo>() }; int position = 1; foreach (var route in RouteTable.Routes.Select(x => x as Route).Where(x => x != null)) { // issue: #33 Fix var httpMethodConstraint = (route.Constraints ?? new RouteValueDictionary())["httpMethod"] as HttpMethodConstraint; ICollection<string> allowedMethods = new string[] { }; if (httpMethodConstraint != null) { allowedMethods = httpMethodConstraint.AllowedMethods; } var namespaces = new string[] { }; if (route.DataTokens != null && route.DataTokens["namespaces"] != null) namespaces = route.DataTokens["namespaces"] as string[]; var defaults = new RouteValueDictionary(); if (route.Defaults != null) defaults = route.Defaults; if (route.DataTokens == null) route.DataTokens = new RouteValueDictionary(); var namedRoute = route as NamedRoute; var routeName = ""; if (namedRoute != null) { routeName = namedRoute.Name; } model.RouteInfos.Add(new RouteInfo { Position = position, HttpMethod = string.Join(" ", allowedMethods.ToArray()), Path = route.Url, Endpoint = defaults["controller"] + "#" + defaults["action"], Area = route.DataTokens["area"] as string, Namespaces = string.Join(" ", namespaces.ToArray()), Name = routeName }); position++; } var debugPath = (from p in model.RouteInfos where p.Endpoint.Equals("routedebug#resources", StringComparison.InvariantCultureIgnoreCase) select p.Path.Replace("{name}", string.Empty)).FirstOrDefault(); model.DebugPath = debugPath; var template = GetTemplate(); return Content(Razor.Parse(template, model)); }
public string Debugger(RouteDebugViewModel model) { var routeInfos = new StringBuilder(); foreach (var routeinfo in model.RouteInfos) { routeInfos.AppendLine(routeinfo.IsUnknown ? "<tr class='unknown'>" : "<tr>"); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Position); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Endpoint); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.HttpMethod); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Name); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Area); routeInfos.AppendFormat("<td class='path'><a href='{0}' target='_blank'>{0}</a></td>", routeinfo.Path); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Namespaces); routeInfos.AppendLine("</tr>"); } return(HtmlPage.Replace("{{routes}}", routeInfos.ToString())); }
public string Debugger(RouteDebugViewModel model) { var style = model.GetPath("style.css"); var jqueryDatatables = model.GetPath("jquery.dataTables.min.js"); var routeInfos = new StringBuilder(); foreach (var routeinfo in model.RouteInfos) { routeInfos.AppendLine("<tr>"); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Position); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Name); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.HttpMethod); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Area); routeInfos.AppendFormat("<td class='path'><a href='{0}' target='_blank'>{0}</a></td>", routeinfo.Path); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Endpoint); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Namespaces); routeInfos.AppendLine("</tr>"); } return string.Format(HtmlPage, style, jqueryDatatables, routeInfos); }
public string Debugger(RouteDebugViewModel model) { var style = model.GetPath("style.css"); var jqueryDatatables = model.GetPath("jquery.dataTables.min.js"); var routeInfos = new StringBuilder(); foreach (var routeinfo in model.RouteInfos) { routeInfos.AppendLine("<tr>"); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Position); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Name); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.HttpMethod); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Area); routeInfos.AppendFormat("<td class='path'><a href='{0}' target='_blank'>{0}</a></td>", routeinfo.Path); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Endpoint); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Namespaces); routeInfos.AppendLine("</tr>"); } return(string.Format(HtmlPage, style, jqueryDatatables, routeInfos)); }
public ActionResult Index() { var model = new RouteDebugViewModel { RouteInfos = new List <RouteInfo>() }; int position = 1; foreach (var route in RouteTable.Routes.Select(x => x as Route).Where(x => x != null)) { // issue: #33 Fix var httpMethodConstraint = (route.Constraints ?? new RouteValueDictionary())["httpMethod"] as HttpMethodConstraint; ICollection <string> allowedMethods = new string[] { }; if (httpMethodConstraint != null) { allowedMethods = httpMethodConstraint.AllowedMethods; } var namespaces = new string[] { }; if (route.DataTokens != null && route.DataTokens["namespaces"] != null) { namespaces = route.DataTokens["namespaces"] as string[]; } var defaults = new RouteValueDictionary(); if (route.Defaults != null) { defaults = route.Defaults; } if (route.DataTokens == null) { route.DataTokens = new RouteValueDictionary(); } var namedRoute = route as NamedRoute; var routeName = ""; if (namedRoute != null) { routeName = namedRoute.Name; } model.RouteInfos.Add(new RouteInfo { Position = position, HttpMethod = string.Join(" ", allowedMethods.ToArray()), Path = route.Url, Endpoint = defaults["controller"] + "#" + defaults["action"], Area = route.DataTokens["area"] as string, Namespaces = string.Join(" ", namespaces.ToArray()), Name = routeName }); position++; } var debugPath = (from p in model.RouteInfos where p.Endpoint.Equals("routedebug#resources", StringComparison.InvariantCultureIgnoreCase) select p.Path.Replace("{name}", string.Empty)).FirstOrDefault(); model.DebugPath = debugPath; var template = GetTemplate(); return(Content(Razor.Parse(template, model))); }
public ActionResult Index() { var model = new RouteDebugViewModel { RouteInfos = new List<RouteInfo>() }; int position = 1; foreach (var routeBase in RouteTable.Routes) { var route = routeBase as Route; if (route != null) { // issue: #33 Fix var httpMethodConstraint = (route.Constraints ?? new RouteValueDictionary())["httpMethod"] as HttpMethodConstraint; ICollection<string> allowedMethods = new string[] { }; if (httpMethodConstraint != null) { allowedMethods = httpMethodConstraint.AllowedMethods; } var namespaces = new string[] { }; if (route.DataTokens != null && route.DataTokens["namespaces"] != null) namespaces = (route.DataTokens["namespaces"] ?? new string[0]) as string[]; var defaults = new RouteValueDictionary(); if (route.Defaults != null) defaults = route.Defaults; if (route.DataTokens == null) route.DataTokens = new RouteValueDictionary(); var namedRoute = route as NamedRoute; var routeName = ""; if (namedRoute != null) { routeName = namedRoute.Name; } model.RouteInfos.Add(new RouteInfo { Position = position, HttpMethod = string.Join(", ", allowedMethods.ToArray()), Path = route.Url, Endpoint = defaults["controller"] + "#" + defaults["action"], Area = route.DataTokens["area"] as string, Namespaces = string.Join(" ", (namespaces).ToArray()), Name = routeName }); } else { const string unknown = "???"; var type = routeBase.GetType(); model.RouteInfos.Add(new RouteInfo { Position = position, HttpMethod = "*", Path = type.FullName, Endpoint = unknown, Area = unknown, Namespaces = type.Namespace, Name = type.Name + " (external)", IsUnknown = true }); } position++; } var debugPath = (from p in model.RouteInfos where p.Endpoint.Equals("routedebug#resources", StringComparison.InvariantCultureIgnoreCase) select p.Path.Replace("{name}", string.Empty)).FirstOrDefault(); model.DebugPath = debugPath; return Content(Debugger(model)); }
public string Debugger(RouteDebugViewModel model) { var routeInfos = new StringBuilder(); foreach (var routeinfo in model.RouteInfos) { routeInfos.AppendLine(routeinfo.IsUnknown ? "<tr class='unknown'>" : "<tr>"); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Position); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Endpoint); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.HttpMethod); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Name); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Area); routeInfos.AppendFormat("<td class='path'><a href='{0}' target='_blank'>{0}</a></td>", routeinfo.Path); routeInfos.AppendFormat("<td>{0}</td>", routeinfo.Namespaces); routeInfos.AppendLine("</tr>"); } return HtmlPage.Replace("{{routes}}", routeInfos.ToString()); }
public ActionResult Index() { var model = new RouteDebugViewModel { RouteInfos = new List <RouteInfo>() }; int position = 1; foreach (var routeBase in RouteTable.Routes) { var route = routeBase as Route; if (route != null) { // issue: #33 Fix var httpMethodConstraint = (route.Constraints ?? new RouteValueDictionary())["httpMethod"] as HttpMethodConstraint; ICollection <string> allowedMethods = new string[] { }; if (httpMethodConstraint != null) { allowedMethods = httpMethodConstraint.AllowedMethods; } var namespaces = new string[] { }; if (route.DataTokens != null && route.DataTokens["namespaces"] != null) { namespaces = (route.DataTokens["namespaces"] ?? new string[0]) as string[]; } var defaults = new RouteValueDictionary(); if (route.Defaults != null) { defaults = route.Defaults; } if (route.DataTokens == null) { route.DataTokens = new RouteValueDictionary(); } var namedRoute = route as NamedRoute; var routeName = ""; if (namedRoute != null) { routeName = namedRoute.Name; } model.RouteInfos.Add(new RouteInfo { Position = position, HttpMethod = string.Join(", ", allowedMethods.ToArray()), Path = route.Url, Endpoint = defaults["controller"] + "#" + defaults["action"], Area = route.DataTokens["area"] as string, Namespaces = string.Join(" ", (namespaces).ToArray()), Name = routeName }); } else { const string unknown = "???"; var type = routeBase.GetType(); model.RouteInfos.Add(new RouteInfo { Position = position, HttpMethod = "*", Path = type.FullName, Endpoint = unknown, Area = unknown, Namespaces = type.Namespace, Name = type.Name + " (external)", IsUnknown = true }); } position++; } var debugPath = (from p in model.RouteInfos where p.Endpoint.Equals("routedebug#resources", StringComparison.InvariantCultureIgnoreCase) select p.Path.Replace("{name}", string.Empty)).FirstOrDefault(); model.DebugPath = debugPath; return(Content(Debugger(model))); }