private string GetRouteExistingFiles(RouteBase routeBase) { try { return(routeBase.GetType().InvokeMember("_routeExistingFiles", System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, routeBase, null) as string); } catch { } return(String.Empty); }
RouteModel CreateModel(RouteBase rb, int index) { RouteModel rm = new RouteModel(); rm.Order = index.ToString(); rm.Type = rb.GetType().FullName; rm.Route = rb; rm.RouteExistingFiles = GetRouteExistingFiles(rb); return(rm); }
RouteModel CreateModel(RouteBase rb, int index) { var rm = new RouteModel { Order = index.ToString(), Type = rb.GetType().FullName, Route = rb, RouteExistingFiles = GetRouteExistingFiles(rb) }; return(rm); }
private static Route _safeCastRouteBaseToRoute(RouteBase routeBase) { Route route = routeBase as Route; if (route == null && routeBase != null) { PropertyInfo property = routeBase.GetType().GetProperty("__DebugRoute", BindingFlags.NonPublic | BindingFlags.Instance); if (property != null) { route = property.GetValue(routeBase, null) as Route; } } return(route); }
private Route CastRoute(RouteBase routeBase) { var route = routeBase as Route; if (route == null) { // cheat! // TODO: Create an interface for self reporting routes. var type = routeBase.GetType(); var property = type.GetProperty("__DebugRoute", BindingFlags.NonPublic | BindingFlags.Instance); if (property != null) { route = property.GetValue(routeBase, null) as Route; } } return(route); }