private static ActionDescriptor GetActionDescriptor(ControllerBase controller, RouteData routeData) { var controllerDescriptor = new ReflectedControllerDescriptor(controller.GetType()); var actionName = routeData.GetRequiredString("action"); var actionDescriptor = controllerDescriptor.FindAction(controller.ControllerContext, actionName); return actionDescriptor; }
private Cog GetRequestedCog(RouteData routeData) { string package = routeData.GetRequiredString("package"); if (routeData.Values.ContainsKey("version")) return Cogs.GetCog(package, new Version(routeData.Values["version"].ToString())); else return Cogs.GetCog(package); }
protected Log(RouteData data, HttpContextBase context) : base(context) { if (data == null) return; var route = data.Route as Route; if (route != null) { this.RouteConstraints = new Dictionary(route.Constraints); this.RouteDefaults = new Dictionary(route.Defaults); this.RouteUrl = route.Url; } this.RouteData = new Dictionary(data.Values); this.DataTokens = new Dictionary(data.DataTokens); this.Action = data.GetRequiredString("action").ToPascal(); this.Controller = data.GetRequiredString("controller").ToPascal(); this.Area = this.DataTokens.ContainsKey("area") ? this.DataTokens["area"].ToPascal() : string.Empty; }
protected virtual string GetAreaName(System.Web.Routing.RouteData routeData) { if (routeData.Values.ContainsKey("pluginName")) { var pluginName = routeData.GetRequiredString("pluginName"); return(pluginName); } object obj2; if (routeData.DataTokens.TryGetValue("area", out obj2)) { return(obj2 as string); } return(GetAreaName(routeData.Route)); }
public override ControllerMeta Create(RouteData data) { TypedControllerMeta meta = null; var accessor = httpContext.ApplicationInstance as IContainerAccessor; if (accessor != null) { var container = accessor.Container; var controllerName = data.GetRequiredString("controller").ToLowerInvariant(); if (!container.Kernel.HasComponent(controllerName)) return null; var args = CreateArgs(); var controller = container.Resolve<object>(controllerName, args); var descriptor = DescriptorBuilder.Build(controller.GetType()); meta = new TypedControllerMeta(controller, descriptor); } return meta; }
private static string GetActionName(RouteData routeData) { //if (DirectRouteExtensions.HasDirectRouteMatch(routeData)) return null; try { return routeData.GetRequiredString("action"); } catch { return null; } }
public MetaTable GetTableFromRouteData (RouteData routeData) { if (routeData == null) throw new ArgumentNullException ("routeData"); var t = routeData.GetRequiredString ("Table"); if (Model == null) throw new InvalidOperationException ("MetaModel must be set to the DynamicDataRoute before retrieving MetaTable"); return Model.GetTable (t); }
public string GetActionFromRouteData (RouteData routeData) { if (routeData == null) throw new ArgumentNullException ("routeData"); return routeData.GetRequiredString ("Action"); }
private bool RouteRequiresPublicCaching(RouteData routeData) { if (routeData == null) { return false; } try { var controller = routeData.GetRequiredString("controller"); var action = routeData.GetRequiredString("action"); return (controller == "Help" && action == "Index"); } catch { // request may be for asset return false; } }
private static string GetViewName(RouteData routeData, string viewName) { return !string.IsNullOrEmpty(viewName) ? viewName : routeData.GetRequiredString("action"); }
/// <summary> /// Extract the MetaTable from the RouteData. Fails if it can't find it /// </summary> /// <param name="routeData">The route data</param> /// <returns>The found MetaTable</returns> public MetaTable GetTableFromRouteData(RouteData routeData) { string tableName = routeData.GetRequiredString(TableToken); return Model.GetTable(tableName); }
public void GetRequiredStringNull () { var d = new RouteData (); d.GetRequiredString (null); }
protected virtual string GetAreaName(RouteData routeData) { if (routeData.Values.ContainsKey("pluginName")) { var pluginName = routeData.GetRequiredString("pluginName"); return pluginName; } object obj2; if (routeData.DataTokens.TryGetValue("area", out obj2)) { return (obj2 as string); } return GetAreaName(routeData.Route); }
private static bool IsActionValid(IEnumerable<string> actionNames, RouteData routeData) { return ((actionNames == null) || actionNames.Contains(routeData.GetRequiredString("action"))); }
public static bool CurrentPageIsBasket(RouteData routeData) { return routeData.GetRequiredString("controller").IsCaseInsensitiveEqual("ShoppingCart") && routeData.GetRequiredString("action").IsCaseInsensitiveEqual("Cart"); }
private static IEnumerable<string> PathForFeatureBundle(RouteData routeData, string extension) { if (!routeData.DataTokens.ContainsKey("area")) { return PathForFeatureBundle( routeData.GetRequiredString("action"), routeData.GetRequiredString("controller"), extension); } else { return PathForFeatureBundle( routeData.GetRequiredString("action"), routeData.GetRequiredString("controller"), routeData.DataTokens["area"] as string, extension); } }
public void GetRequiredStringNonexistent () { var d = new RouteData (); d.GetRequiredString ("a"); }
public void GetRequiredStringForNonStringValue () { var d = new RouteData (); d.Values.Add ("a", 10); Assert.AreEqual ("10", d.GetRequiredString ("a")); }
public void GetRequiredStringExistent () { var d = new RouteData (); d.Values.Add ("a", "x"); Assert.AreEqual ("x", d.GetRequiredString ("a")); }
private static bool IsControllerValid(string controllerName, RouteData routeData) { return ((String.IsNullOrEmpty(controllerName)) || (routeData.GetRequiredString("controller") == controllerName)); }
public static string SortableColumn(this HtmlHelper htmlHelper, string linkText, string columnName, object routeValues) { //automatically determine the current action System.Web.Routing.RouteData data = htmlHelper.ViewContext.Controller.ControllerContext.RouteData; string actionName = data.GetRequiredString("action"); StringBuilder sb = new StringBuilder(); var vals = new RouteValueDictionary(routeValues); string sidx = String.Empty; if (System.Web.HttpContext.Current.Request["sidx"] != null) { sidx = System.Web.HttpContext.Current.Request["sidx"].ToString(); } //modify the sidx if (vals.ContainsKey("sidx") == false) { vals.Add("sidx", columnName); } else { vals["sidx"] = columnName; } //get the sort order from the request variable if it exists string sord = String.Empty; if (System.Web.HttpContext.Current.Request["sord"] != null) { sord = System.Web.HttpContext.Current.Request["sord"].ToString(); } //add the sord key if needed if (vals.ContainsKey("sord") == false) { vals.Add("sord", String.Empty); } //if column matches if (sidx.Equals(columnName, StringComparison.CurrentCultureIgnoreCase) == true) { if (sord.Equals("asc", StringComparison.CurrentCultureIgnoreCase) == true) { //draw the ascending sort indicator using the wingdings font. sb.Append(" <font face='Wingdings 3'>p</font>"); vals["sord"] = "desc"; } else { sb.Append(" <font face='Wingdings 3'>q</font>"); vals["sord"] = "asc"; } } else { //if the column does not match then force the next sort to ascending order vals["sord"] = "asc"; } //Use the ActionLink to build the link and insert it into the string sb.Insert(0, System.Web.Mvc.Html.LinkExtensions.ActionLink(htmlHelper, linkText, actionName, vals)); return(sb.ToString()); }
/// <summary> /// Extract the Action from the RouteData. Fails if it can't find it /// </summary> /// <param name="routeData">The route data</param> /// <returns>The found Action</returns> public string GetActionFromRouteData(RouteData routeData) { return routeData.GetRequiredString(ActionToken); }
public static string GetViewPath(RouteData routeData) { if (routeData == null) throw new ArgumentNullException("routeData"); var controllerName = routeData.GetRequiredString("Controller"); var actionName = routeData.GetRequiredString("Action"); var area = routeData.Values["area"] ?? routeData.DataTokens["area"]; return area != null ? string.Format("/{0}/{1}/{2}", area, controllerName, actionName) : string.Format("/{0}/{1}", controllerName, actionName); }