本文整理汇总了C#中System.Web.Routing.RouteBase.IsDirectRoute方法的典型用法代码示例。如果您正苦于以下问题:C# RouteBase.IsDirectRoute方法的具体用法?C# RouteBase.IsDirectRoute怎么用?C# RouteBase.IsDirectRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Routing.RouteBase
的用法示例。
在下文中一共展示了RouteBase.IsDirectRoute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRouteData
private static RouteData CreateRouteData(RouteBase route, RouteValueDictionary routeValues, RouteValueDictionary dataTokens, ViewContext parentViewContext)
{
RouteData routeData = new RouteData();
foreach (KeyValuePair<string, object> kvp in routeValues)
{
routeData.Values.Add(kvp.Key, kvp.Value);
}
foreach (KeyValuePair<string, object> kvp in dataTokens)
{
routeData.DataTokens.Add(kvp.Key, kvp.Value);
}
routeData.Route = route;
routeData.DataTokens[ControllerContext.ParentActionViewContextToken] = parentViewContext;
// It's possible that the outgoing route is a direct route - in which case it's not possible to reach using
// the action name and controller name. We need to check for that case to determine if we need to create a
// 'direct route' routedata to reach it.
if (route.IsDirectRoute())
{
// Codeplex-2136 - ControllerContext.IsChildAction returns false inside Controller.Initialize()
//
// We're constructing a 'temp' route data to wrap the route data for the match we're invoking via
// an attribute route. The ControllerContext will look at datatokens to see if it's being invoked
// as a child action.
//
// By sticking the view context on both route data ControllerContext will do the right thing
// at all parts of the pipeline.
var directRouteData = RouteCollectionRoute.CreateDirectRouteMatch(route, new List<RouteData>() { routeData });
directRouteData.DataTokens[ControllerContext.ParentActionViewContextToken] = parentViewContext;
return directRouteData;
}
else
{
return routeData;
}
}
示例2: CreateRouteData
private static RouteData CreateRouteData(RouteBase route, RouteValueDictionary routeValues, RouteValueDictionary dataTokens, ViewContext parentViewContext)
{
RouteData routeData = new RouteData();
foreach (KeyValuePair<string, object> kvp in routeValues)
{
routeData.Values.Add(kvp.Key, kvp.Value);
}
foreach (KeyValuePair<string, object> kvp in dataTokens)
{
routeData.DataTokens.Add(kvp.Key, kvp.Value);
}
routeData.Route = route;
routeData.DataTokens[ControllerContext.ParentActionViewContextToken] = parentViewContext;
// It's possible that the outgoing route is a direct route - in which case it's not possible to reach using
// the action name and controller name. We need to check for that case to determine if we need to create a
// 'direct route' routedata to reach it.
if (route.IsDirectRoute())
{
return RouteCollectionRoute.CreateDirectRouteMatch(route, new List<RouteData>() { routeData });
}
else
{
return routeData;
}
}