当前位置: 首页>>代码示例>>C#>>正文


C# RouteCollection.GetReadLock方法代码示例

本文整理汇总了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;
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:36,代码来源:RouteCollectionExtensions.cs

示例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;
        }
开发者ID:imranbaloch,项目名称:ImranB.ModelBindingFix,代码行数:28,代码来源:RouteCollectionExtensions.cs

示例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);
                }
            }

            
        }
开发者ID:calebjenkins,项目名称:RouteMagic,代码行数:25,代码来源:RouteDebugger.cs

示例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;
 }
开发者ID:anurse,项目名称:MaVeriCk,代码行数:13,代码来源:ModuleRouteRewriter.cs

示例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);
     }
 }
开发者ID:dpawatts,项目名称:zeus,代码行数:18,代码来源:RouteDebugger.cs

示例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;
        }
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:18,代码来源:RouteCollectionExtensions.cs


注:本文中的RouteCollection.GetReadLock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。