本文整理汇总了C#中RouteCollection.GetWriteLock方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.GetWriteLock方法的具体用法?C# RouteCollection.GetWriteLock怎么用?C# RouteCollection.GetWriteLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.GetWriteLock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
private static void Register(RouteCollection routes, IEnumerable<RouteItem> routeItems)
{
using (var @lock = routes.GetWriteLock())
{
routes.Clear();
foreach (var routeItem in routeItems.Where(r => !r.Disabled))
{
routes.Add(routeItem.Name, new RouteAdapter(routeItem));
}
}
}
示例2: RegisterRoutes
/// <summary>
/// Register all routes defined in the RouteMappingConfiguration
/// </summary>
/// <param name="routes">RouteCollection to add routes</param>
/// <param name="config">Routes to register</param>
public static void RegisterRoutes(RouteCollection routes, RouteMappingConfiguration config)
{
if (config == null)
{
throw new NullReferenceException("Route mapping configuration not defined.");
}
using (routes.GetWriteLock())
{
foreach (RouteElement ignoreItem in config.IgnoreRoutes)
{
routes.IgnoreRoute(ignoreItem.Url);
}
foreach (RouteElement item in config.Routes)
{
var lowerCaseOnly = item.LowerCaseOnly == null ? config.Routes.LowerCaseOnly : item.LowerCaseOnly.Value;
var route = new StrictRoute(item.Url, new MvcRouteHandler(), lowerCaseOnly);
route.Defaults = new RouteValueDictionary();
route.Defaults.Add("Controller", item.Controller);
route.Defaults.Add("Action", item.Action);
if (item.Defaults != null)
{
foreach (string key in item.Defaults.AllKeys)
{
route.Defaults.Add(key, item.Defaults[key].Value);
}
}
if (item.Constraints != null)
{
route.Constraints = new RouteValueDictionary();
foreach (string key in item.Constraints.AllKeys)
{
route.Constraints.Add(key, new RegexConstraint(item.Constraints[key].Value));
}
}
if (item.Namespace != null)
{
if (route.DataTokens == null)
{
route.DataTokens = new RouteValueDictionary();
}
route.DataTokens["Namespaces"] = new string[] { item.Namespace };
}
routes.Add(route);
}
}
}
示例3: MapRoutes
public static void MapRoutes(RouteCollection routes, ContextualPublishedCache umbracoCache)
{
//find all articulate root nodes
var articulateNodes = umbracoCache.GetByXPath("//Articulate").ToArray();
//NOTE: need to write lock because this might need to be remapped while the app is running if
// any articulate nodes are updated with new values
using (routes.GetWriteLock())
{
//clear the existing articulate routes (if any)
RemoveExisting(routes);
// For each articulate root, we need to create some custom route, BUT routes can overlap
// based on multi-tenency so we need to deal with that.
// For example a root articulate node might yield a route like:
// /
// and another articulate root node that has a domain might have this url:
// http://mydomain/
// but when that is processed through RoutePathFromNodeUrl, it becomes:
// /
// which already exists and is already assigned to a specific node ID.
// So what we need to do in these cases is use a special route handler that takes
// into account the domain assigned to the route.
var groups = articulateNodes
.GroupBy(x => RouteCollectionExtensions.RoutePathFromNodeUrl(x.Url))
//This is required to ensure that we create routes that are more specific first
// before creating routes that are less specific
.OrderByDescending(x => x.Key.Split('/').Length);
foreach (var grouping in groups)
{
var nodesAsArray = grouping.ToArray();
MapRssRoute(routes, grouping.Key, nodesAsArray);
MapSearchRoute(routes, grouping.Key, nodesAsArray);
MapTagsAndCategoriesRoute(routes, grouping.Key, nodesAsArray);
MapMarkdownEditorRoute(routes, grouping.Key, nodesAsArray);
foreach (var content in grouping)
{
MapMetaWeblogRoute(routes, grouping.Key, content);
MapManifestRoute(routes, grouping.Key, content);
MapRsdRoute(routes, grouping.Key, content);
}
}
}
}
示例4: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
using (routes.GetWriteLock())
{
routes.Insert(
0,
new Route(
CacheTagMvcSettings.RouteUrl,
new RouteValueDictionary(new {controller = "CacheTag", action = "Resource"}),
new MvcRouteHandler()
)
);
routes.Insert(
0,
new Route(
CacheTagMvcSettings.RouteUrl + ".{ext}",
new RouteValueDictionary(new { controller = "CacheTag", action = "Resource", ext = UrlParameter.Optional }),
new MvcRouteHandler()
)
);
}
}
示例5: MapRoutes
public static void MapRoutes(RouteCollection routes, ContextualPublishedCache umbracoCache)
{
//find all Dialogue forum root nodes - Testing adding new line
var dialogueNodes = umbracoCache.GetByXPath(string.Concat("//", AppConstants.DocTypeForumRoot)).ToArray();
//NOTE: need to write lock because this might need to be remapped while the app is running if
// any articulate nodes are updated with new values
using (routes.GetWriteLock())
{
//clear the existing articulate routes (if any)
RemoveExisting(routes);
// For each articulate root, we need to create some custom route, BUT routes can overlap
// based on multi-tenency so we need to deal with that.
// For example a root articulate node might yield a route like:
// /
// and another articulate root node that has a domain might have this url:
// http://mydomain/
// but when that is processed through RoutePathFromNodeUrl, it becomes:
// /
// which already exists and is already assigned to a specific node ID.
// So what we need to do in these cases is use a special route handler that takes
// into account the domain assigned to the route.
var groups = dialogueNodes.GroupBy(x => RouteCollectionExtensions.RoutePathFromNodeUrl(x.Url));
foreach (var grouping in groups)
{
var nodesAsArray = grouping.ToArray();
MapTopicRoute(routes, grouping.Key, nodesAsArray);
MapDialoguePages(routes, grouping.Key, nodesAsArray);
MapMemberRoute(routes, grouping.Key, nodesAsArray);
}
}
}