本文整理汇总了C#中System.Web.Routing.RouteData.GetRequiredString方法的典型用法代码示例。如果您正苦于以下问题:C# RouteData.GetRequiredString方法的具体用法?C# RouteData.GetRequiredString怎么用?C# RouteData.GetRequiredString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Routing.RouteData
的用法示例。
在下文中一共展示了RouteData.GetRequiredString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetActionDescriptor
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;
}
示例2: GetRequestedCog
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);
}
示例3: Log
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;
}
示例4: Create
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;
}
示例5: IsControllerValid
private static bool IsControllerValid(string controllerName, RouteData routeData)
{
return ((String.IsNullOrEmpty(controllerName)) || (routeData.GetRequiredString("controller") == controllerName));
}
示例6: IsActionValid
private static bool IsActionValid(IEnumerable<string> actionNames, RouteData routeData)
{
return ((actionNames == null) || actionNames.Contains(routeData.GetRequiredString("action")));
}
示例7: GetActionName
private static string GetActionName(RouteData routeData)
{
//if (DirectRouteExtensions.HasDirectRouteMatch(routeData)) return null;
try
{
return routeData.GetRequiredString("action");
}
catch
{
return null;
}
}
示例8: GetTableFromRouteData
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);
}
示例9: GetActionFromRouteData
public string GetActionFromRouteData (RouteData routeData)
{
if (routeData == null)
throw new ArgumentNullException ("routeData");
return routeData.GetRequiredString ("Action");
}
示例10: RouteRequiresPublicCaching
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;
}
}
示例11: GetViewName
private static string GetViewName(RouteData routeData, string viewName)
{
return !string.IsNullOrEmpty(viewName)
? viewName
: routeData.GetRequiredString("action");
}
示例12: GetRequiredStringNull
public void GetRequiredStringNull ()
{
var d = new RouteData ();
d.GetRequiredString (null);
}
示例13: GetAreaName
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);
}
示例14: GetTableFromRouteData
/// <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);
}
示例15: CurrentPageIsBasket
public static bool CurrentPageIsBasket(RouteData routeData)
{
return routeData.GetRequiredString("controller").IsCaseInsensitiveEqual("ShoppingCart")
&& routeData.GetRequiredString("action").IsCaseInsensitiveEqual("Cart");
}