本文整理汇总了C#中RouteCollection.GetReadLock方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.GetReadLock方法的具体用法?C# RouteCollection.GetReadLock怎么用?C# RouteCollection.GetReadLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.GetReadLock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterRouteCollectionByArea
// This method returns a new RouteCollection containing only routes that matched a particular area.
// The Boolean out parameter is just a flag specifying whether any registered routes were area-aware.
private static RouteCollection FilterRouteCollectionByArea(RouteCollection routes, string areaName, out bool usingAreas)
{
if (areaName == null)
{
areaName = String.Empty;
}
usingAreas = false;
// Ensure that we continue using the same settings as the previous route collection
// if we are using areas and the route collection is exchanged
RouteCollection filteredRoutes = new RouteCollection()
{
AppendTrailingSlash = routes.AppendTrailingSlash,
LowercaseUrls = routes.LowercaseUrls,
RouteExistingFiles = routes.RouteExistingFiles
};
using (routes.GetReadLock())
{
foreach (RouteBase route in routes)
{
string thisAreaName = AreaHelpers.GetAreaName(route) ?? String.Empty;
usingAreas |= (thisAreaName.Length > 0);
if (String.Equals(thisAreaName, areaName, StringComparison.OrdinalIgnoreCase))
{
filteredRoutes.Add(route);
}
}
}
// if areas are not in use, the filtered route collection might be incorrect
return (usingAreas) ? filteredRoutes : routes;
}
示例2: FilterRouteCollectionByArea
// This method returns a new RouteCollection containing only routes that matched a particular area.
// The Boolean out parameter is just a flag specifying whether any registered routes were area-aware.
private static RouteCollection FilterRouteCollectionByArea(RouteCollection routes, string areaName, out bool usingAreas)
{
if (areaName == null)
{
areaName = String.Empty;
}
usingAreas = false;
RouteCollection filteredRoutes = new RouteCollection();
using (routes.GetReadLock())
{
foreach (RouteBase route in routes)
{
string thisAreaName = AreaHelpers.GetAreaName(route) ?? String.Empty;
usingAreas |= (thisAreaName.Length > 0);
if (String.Equals(thisAreaName, areaName, StringComparison.OrdinalIgnoreCase))
{
filteredRoutes.Add(route);
}
}
}
// if areas are not in use, the filtered route collection might be incorrect
return (usingAreas) ? filteredRoutes : routes;
}
示例3: RewriteRoutesForTesting
public static void RewriteRoutesForTesting(RouteCollection routes)
{
using (routes.GetReadLock())
{
bool foundDebugRoute = false;
foreach (RouteBase routeBase in routes)
{
Route route = routeBase as Route;
if (route != null)
{
route.RouteHandler = new DebugRouteHandler();
}
if (route == DebugRoute.Singleton)
foundDebugRoute = true;
}
if (!foundDebugRoute)
{
routes.Add(DebugRoute.Singleton);
}
}
}
示例4: GetVirtualPathOnAllRoutes
// RouteCollection.GetVirtualPath does extra processing we don't want here
private static VirtualPathData GetVirtualPathOnAllRoutes(RouteCollection routes, RequestContext requestContext, RouteValueDictionary values)
{
using (routes.GetReadLock()) {
foreach (RouteBase route in routes) {
VirtualPathData pathData = route.GetVirtualPath(requestContext, values);
if (pathData != null) {
return pathData;
}
}
}
return null;
}
示例5: RewriteRoutesForTesting
// Methods
public static void RewriteRoutesForTesting(RouteCollection routes)
{
using (routes.GetReadLock())
{
bool flag = false;
foreach (RouteBase base2 in routes)
{
Route route = base2 as Route;
if (route != null)
route.RouteHandler = new DebugRouteHandler();
if (route == DebugRoute.Singleton)
flag = true;
}
if (!flag)
routes.Add(DebugRoute.Singleton);
}
}
示例6: FilterRouteCollectionByArea
private static RouteCollection FilterRouteCollectionByArea(RouteCollection routes, string areaName) {
if (areaName == null) {
areaName = String.Empty;
}
RouteCollection filteredRoutes = new RouteCollection();
using (routes.GetReadLock()) {
foreach (RouteBase route in routes) {
string thisAreaName = AreaHelpers.GetAreaName(route) ?? String.Empty;
if (String.Equals(thisAreaName, areaName, StringComparison.OrdinalIgnoreCase)) {
filteredRoutes.Add(route);
}
}
}
return filteredRoutes;
}