本文整理汇总了C#中RouteValueDictionary.Union方法的典型用法代码示例。如果您正苦于以下问题:C# RouteValueDictionary.Union方法的具体用法?C# RouteValueDictionary.Union怎么用?C# RouteValueDictionary.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteValueDictionary
的用法示例。
在下文中一共展示了RouteValueDictionary.Union方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterRoute
public static void RegisterRoute(RouteCollection route)
{
route.RouteExistingFiles = true;
route.LowercaseUrls = true;
route.Ignore("{resource}.ashx/{*pathInfo}");
route.Ignore("{resource}.axd/{*pathInfo}");
RouteValueDictionary defaultValue = new RouteValueDictionary { { "pages", "login.aspx" } };
RouteValueDictionary contains = new RouteValueDictionary { { "pages", @"[a-zA-Z0-9/]*" } };
//route.Add("ashx", new Route("{path}.ashx", new PageRouteHandler("~/{path}.ashx")));
//管理员页面
route.MapPageRoute(
"admin-login",
"admin/",
"~/admin/login.aspx",
true
);
route.MapPageRoute(
"admin",
"admin/{pages}.aspx",
"~/admin/{pages}.aspx",
true,
defaultValue, contains
);
route.MapPageRoute(
"admin2",
"admin/{pages}",
"~/admin/{pages}.aspx",
true,
defaultValue, contains
);
//route.Add("admin", new Route("admin/", new AdminRouteHandler()));
RouteValueDictionary pageIndex = new RouteValueDictionary { { "pageIndex", "1" } };
RouteValueDictionary pageIndexC = new RouteValueDictionary { { "pageIndex", @"^[1-9][0-9]{0,10}$" } };
RouteValueDictionary otherName = new RouteValueDictionary { { "othername", "" } };
RouteValueDictionary otherNameC = new RouteValueDictionary { { "othername", @"^((?!\S*?[\.])(?!\S*?[\-_\.]{2,})[a-zA-Z0-9\-\._]{0,}[^\.])?$" } };
RouteValueDictionary all = new RouteValueDictionary {
{ "prev", "" },
{ "pageIndex", "1" },
{ "othername", "" }
};
RouteValueDictionary allC = new RouteValueDictionary {
{ "prev", PREV },
{"pageIndex",PAGE_INDEX},
{"othername",OTHER_NAME}
};
var p = new RouteValueDictionary(otherName.Union(pageIndex));
//首页
route.Add(
"default",
new Route("", new BulaqRouteHandler())
);
//route.Add(
// "alll1", new Route("{prev}/{pageIndex}", all, allC, new BulaqRouteHandler())
// );
route.Add(
"defaultRoute1", new Route("{pageIndex}", new RouteValueDictionary { { "pageIndex", "1" } }, new RouteValueDictionary { { "pageIndex", PAGE_INDEX } }, allC, new BulaqRouteHandler())
);
route.Add(
"defaultRoute", new Route("{prev}/{othername}/{pageIndex}", all, allC, new BulaqRouteHandler())
);
//自定义页面
route.Add("custompage", new Route("{othername}", otherName, otherNameC, new BulaqRouteHandler()));
}
示例2: Combine
public static RouteValueDictionary Combine(RouteValueDictionary v1, RouteValueDictionary v2)
{
return new RouteValueDictionary(v1.Union(v2).ToDictionary(x => x.Key, y => y.Value));
}