本文整理汇总了C#中System.Web.Routing.RouteData.GetAreaName方法的典型用法代码示例。如果您正苦于以下问题:C# RouteData.GetAreaName方法的具体用法?C# RouteData.GetAreaName怎么用?C# RouteData.GetAreaName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Routing.RouteData
的用法示例。
在下文中一共展示了RouteData.GetAreaName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_Resolve_Route_AreaName_Correctly
public void Should_Resolve_Route_AreaName_Correctly()
{
var dictionary = new RouteValueDictionary();
dictionary["area"] = "TestAreaName";
var handler = new PageRouteHandler("~/Views");
var route = new Route("url", null, null, dictionary, handler);
var routeData = new RouteData(route, handler);
var areaName = routeData.GetAreaName();
Assert.AreEqual(areaName, "TestAreaName");
}
示例2: SetMvcArea
protected virtual void SetMvcArea(RouteData routeData)
{
if (routeData != null)
{
if (!routeData.Values.ContainsKey("area"))
{
routeData.Values.Add("area", routeData.GetAreaName());
}
}
}
示例3: Should_return_the_are_name_from_data_tokens
public void Should_return_the_are_name_from_data_tokens()
{
// Arrange
var routeData = new RouteData();
routeData.DataTokens.Add("area", "AreaName");
// Act
var areaName = routeData.GetAreaName();
// Assert
Assert.That(areaName, Is.EqualTo("AreaName"));
}
示例4: SetMvcArea
private static void SetMvcArea(RouteData routeData)
{
if (routeData != null)
{
if (!routeData.Values.ContainsKey("area"))
{
routeData.Values.Add("area", routeData.GetAreaName());
}
}
}