本文整理汇总了C#中System.Web.Routing.RouteBase类的典型用法代码示例。如果您正苦于以下问题:C# RouteBase类的具体用法?C# RouteBase怎么用?C# RouteBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RouteBase类属于System.Web.Routing命名空间,在下文中一共展示了RouteBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetRouteDescriptorKey
public string GetRouteDescriptorKey(HttpContextBase httpContext, RouteBase routeBase) {
var route = routeBase as Route;
var dataTokens = new RouteValueDictionary();
if (route != null) {
dataTokens = route.DataTokens;
}
else {
var routeData = routeBase.GetRouteData(httpContext);
if (routeData != null) {
dataTokens = routeData.DataTokens;
}
}
var keyBuilder = new StringBuilder();
if (route != null) {
keyBuilder.AppendFormat("url={0};", route.Url);
}
// the data tokens are used in case the same url is used by several features, like *{path} (Rewrite Rules and Home Page Provider)
if (dataTokens != null) {
foreach (var key in dataTokens.Keys) {
keyBuilder.AppendFormat("{0}={1};", key, dataTokens[key]);
}
}
return keyBuilder.ToString().ToLowerInvariant();
}
开发者ID:mikmakcar,项目名称:orchard_fork_learning,代码行数:30,代码来源:CacheService.cs
示例2: CreateAmbiguousControllerException
/// <summary>
/// Creates the ambiguous controller exception.
/// </summary>
/// <param name="route">The route.</param>
/// <param name="controllerName">Name of the controller.</param>
/// <param name="matchingTypes">The matching types.</param>
/// <returns></returns>
internal static InvalidOperationException CreateAmbiguousControllerException(RouteBase route, string controllerName, ICollection<Type> matchingTypes)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (Type current in matchingTypes)
{
stringBuilder.AppendLine();
stringBuilder.Append(current.FullName);
}
Route route2 = route as Route;
string message;
if (route2 != null)
{
message = string.Format(CultureInfo.CurrentUICulture,
"The request for '{0}' has found the following matching controllers:{2}\r\n\r\nMultiple types were found that match the controller named '{0}'. This can happen if the route that services this request does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.",
new object[]
{
controllerName,
route2.Url,
stringBuilder
});
}
else
{
message = string.Format(CultureInfo.CurrentUICulture,
"The request for '{0}' has found the following matching controllers:{2}\r\n\r\nMultiple types were found that match the controller named '{0}'.",
new object[]
{
controllerName,
stringBuilder
});
}
return new InvalidOperationException(message);
}
开发者ID:doublekill,项目名称:MefContrib,代码行数:40,代码来源:CompositionControllerFactory.cs
示例3: CreateAmbiguousControllerException
internal static InvalidOperationException CreateAmbiguousControllerException(RouteBase route, string controllerName, ICollection<Type> matchingTypes)
{
// we need to generate an exception containing all the controller types
StringBuilder typeList = new StringBuilder();
foreach (Type matchedType in matchingTypes)
{
typeList.AppendLine();
typeList.Append(matchedType.FullName);
}
string errorText;
Route castRoute = route as Route;
if (castRoute != null)
{
errorText = String.Format(CultureInfo.CurrentCulture, MvcResources.DefaultControllerFactory_ControllerNameAmbiguous_WithRouteUrl,
controllerName, castRoute.Url, typeList);
}
else
{
errorText = String.Format(CultureInfo.CurrentCulture, MvcResources.DefaultControllerFactory_ControllerNameAmbiguous_WithoutRouteUrl,
controllerName, typeList);
}
return new InvalidOperationException(errorText);
}
开发者ID:haoduotnt,项目名称:aspnetwebstack,代码行数:25,代码来源:DefaultControllerFactory.cs
示例4: RedirectRoute
public RedirectRoute(RouteBase sourceRoute, RouteBase targetRoute, bool permanent, Func<RequestContext, RouteValueDictionary> additionalRouteValues)
{
SourceRoute = sourceRoute;
TargetRoute = targetRoute;
Permanent = permanent;
AdditionalRouteValuesFunc = additionalRouteValues;
}
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:7,代码来源:RedirectRoute.cs
示例5: VirtualPathData
public VirtualPathData (RouteBase route, string virtualPath)
{
// arguments can be null.
Route = route;
VirtualPath = virtualPath;
DataTokens = new RouteValueDictionary ();
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:7,代码来源:VirtualPathData.cs
示例6: RouteData
public RouteData(RouteBase route, IRouteHandler routeHandler)
{
this._values = new RouteValueDictionary();
this._dataTokens = new RouteValueDictionary();
this.Route = route;
this.RouteHandler = routeHandler;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:RouteData.cs
示例7: GetControllerTypeWithinNamespaces
// Copied ALMOST verbatim from DefaultControllerFactory, modified as necessary to avoid dependency on the ASP.NET hosted infrastructure
private Type GetControllerTypeWithinNamespaces(RouteBase route, string controllerName, HashSet<string> namespaces)
{
// Once the master list of controllers has been created we can quickly index into it
// GKM - Not available... ControllerTypeCache.EnsureInitialized(BuildManager);
ICollection<Type> matchingTypes = ControllerTypeCache.GetControllerTypes(controllerName, namespaces);
switch (matchingTypes.Count)
{
case 0:
// no matching types
return null;
case 1:
// single matching type
return matchingTypes.First();
default:
// multiple matching types
throw new Exception(
string.Format("Ambiguous controller match for for controller '{0}' in namespaces '{1}'.",
controllerName, string.Join(", ", namespaces.ToArray())));
// GKM: Internal --> throw CreateAmbiguousControllerException(route, controllerName, matchingTypes);
}
}
开发者ID:sybrix,项目名称:EdFi-App,代码行数:26,代码来源:TestEdFiControllerFactory.cs
示例8: RedirectRoute
public RedirectRoute(RouteBase sourceRoute, RouteBase targetRoute, bool permanent, RouteValueDictionary additionalRouteValues)
{
SourceRoute = sourceRoute;
TargetRoute = targetRoute;
Permanent = permanent;
AdditionalRouteValues = additionalRouteValues;
}
开发者ID:philpeace,项目名称:RouteMagic,代码行数:7,代码来源:RedirectRoute.cs
示例9: RouteData
public RouteData (RouteBase route, IRouteHandler routeHandler)
{
// arguments can be null.
Route = route;
RouteHandler = routeHandler;
DataTokens = new RouteValueDictionary ();
Values = new RouteValueDictionary ();
}
开发者ID:nobled,项目名称:mono,代码行数:9,代码来源:RouteData.cs
示例10: NormalizeRoute
public NormalizeRoute(RouteBase route, bool requireLowerCase, bool appendTrailingSlash)
: base(route)
{
if (route == null) {
throw new ArgumentNullException("route");
}
AppendTrailingSlash = appendTrailingSlash;
RequireLowerCase = requireLowerCase;
}
开发者ID:intertrendSoftware,项目名称:RouteMagic-ITFork,代码行数:9,代码来源:NormalizeRoute.cs
示例11: GetAreaToken
private string GetAreaToken(RouteBase routeBase)
{
var route = routeBase as Route;
if (route == null || route.DataTokens == null)
{
return null;
}
return route.DataTokens["area"] as string;
}
开发者ID:sidlovskyy,项目名称:MVC3-Lowercase-Routes,代码行数:9,代码来源:LowercaseRouteDecorator.cs
示例12: BuildRoute
static string BuildRoute(RouteBase routeBase)
{
var route = ((Route)routeBase);
var allowedMethods = ((HttpMethodConstraint)route.Constraints["httpMethod"]).AllowedMethods;
return string.Format("{0} {1} => {2}#{3}",
DisplayAllowedMethods(allowedMethods),
string.IsNullOrEmpty(route.Url) ? "/" : route.Url,
route.Defaults["controller"],
route.Defaults["action"]);
}
开发者ID:BDDCloud,项目名称:SimpleCMS,代码行数:10,代码来源:Routes.cs
示例13: ShellRoute
public ShellRoute(RouteBase route, ShellSettings shellSettings, IWorkContextAccessor workContextAccessor, IRunningShellTable runningShellTable) {
_route = route;
_shellSettings = shellSettings;
_runningShellTable = runningShellTable;
_workContextAccessor = workContextAccessor;
if (!string.IsNullOrEmpty(_shellSettings.RequestUrlPrefix))
_urlPrefix = new UrlPrefix(_shellSettings.RequestUrlPrefix);
Area = route.GetAreaName();
}
开发者ID:sjbisch,项目名称:Orchard,代码行数:10,代码来源:ShellRoute.cs
示例14: NormalizeRoute
public NormalizeRoute(RouteBase route, bool requireLowerCase, bool appendTrailingSlash)
{
if (route == null)
{
throw new ArgumentNullException("route");
}
this.InternalRoute = route;
this.AppendTrailingSlash = appendTrailingSlash;
this.RequireLowerCase = requireLowerCase;
}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:10,代码来源:NormalizeRoute.cs
示例15: GetAreaName
protected virtual string GetAreaName(RouteBase route) {
var area = route as IRouteWithArea;
if(area != null) {
return area.Area;
}
var route2 = route as Route;
if((route2 != null) && (route2.DataTokens != null)) {
return (route2.DataTokens["area"] as string);
}
return null;
}
开发者ID:jasonholloway,项目名称:brigita,代码行数:11,代码来源:BrigitaViewEngine.cs
示例16: ShellRoute
public ShellRoute(RouteBase route, ShellSettings shellSettings, IWorkContextAccessor workContextAccessor, IRunningShellTable runningShellTable, Func<IDictionary<string, object>, Task> pipeline) {
_route = route;
_shellSettings = shellSettings;
_runningShellTable = runningShellTable;
_pipeline = pipeline;
_workContextAccessor = workContextAccessor;
if (!string.IsNullOrEmpty(_shellSettings.RequestUrlPrefix))
_urlPrefix = new UrlPrefix(_shellSettings.RequestUrlPrefix);
Area = route.GetAreaName();
}
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:11,代码来源:ShellRoute.cs
示例17: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes, ref RouteBase signalRHubRoute)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
signalRHubRoute = routes.MapHubs();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
开发者ID:noobouse,项目名称:NGChat,代码行数:12,代码来源:RouteConfig.cs
示例18: findRouteName
public static string findRouteName(RouteBase _Route, IDictionary<string, RouteBase> _RouteNames, bool remove = true)
{
string _Result = "";
foreach (KeyValuePair<string, RouteBase> _RoutePair in _RouteNames) {
if (_RoutePair.Value == _Route) {
_Result = _RoutePair.Key;
_RouteNames.Remove(_RoutePair);
break;
}
}
return _Result;
}
开发者ID:intertrendSoftware,项目名称:RouteMagic-ITFork,代码行数:12,代码来源:RouteExtensions.cs
示例19: GetURL
internal static string GetURL(RouteBase route, RequestContext context, IResource resource)
{
var location = resource.Location;
var values = new RouteValueDictionary();
if (location is TypeLocation)
{
TypeLocation tl = location as TypeLocation;
values.Add("assembly", tl.ProxyType.Assembly.GetName().Name);
values.Add("name", tl.ProxyType.FullName);
}
else if (location is EmbeddedLocation)
{
EmbeddedLocation el = location as EmbeddedLocation;
values.Add("assembly", el.Assembly.GetName().Name);
values.Add("name", el.ResourceName);
}
else if (location is VirtualPathLocation)
{
VirtualPathLocation vl = location as VirtualPathLocation;
if (!(resource is IProxyResource))
return UrlHelper.GenerateContentUrl(vl.VirtualPath, context.HttpContext);
var p = vl.VirtualPath;
if (p[0] == '/') p = p.Substring(1);
values.Add("name", p);
}
else if (location is ExternalLocation)
{
ExternalLocation el = location as ExternalLocation;
return el.Uri.ToString();
}
else
throw new Exception("Unknown IResourceLocationType");
var pr = resource as IProxyResource;
if (pr != null && (pr.CultureSensitive || pr.CultureUISensitive))
{
if (pr.CultureSensitive)
values.Add("culture", CultureInfo.CurrentCulture.LCID.ToString("x"));
if (pr.CultureUISensitive)
values.Add("cultureUI", CultureInfo.CurrentUICulture.LCID.ToString("x"));
}
values.Add("version", ToHex(resource.Version));
var virtualPath = route.GetVirtualPath(context, values);
if (virtualPath == null) throw new Exception("Routing is incomplete.");
var url = UrlHelper.GenerateContentUrl("~/" + virtualPath.VirtualPath, context.HttpContext);
return url;
}
开发者ID:sebmarkbage,项目名称:calyptus.resourcemanager,代码行数:52,代码来源:RoutingResourceURLFactory.cs
示例20: GetAreaName
public static string GetAreaName(RouteBase route) {
IRouteWithArea routeWithArea = route as IRouteWithArea;
if (routeWithArea != null) {
return routeWithArea.Area;
}
Route castRoute = route as Route;
if (castRoute != null && castRoute.DataTokens != null) {
return castRoute.DataTokens["area"] as string;
}
return null;
}
开发者ID:nobled,项目名称:mono,代码行数:13,代码来源:AreaHelpers.cs
注:本文中的System.Web.Routing.RouteBase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论