本文整理汇总了C#中System.Web.Routing.RouteBase类的典型用法代码示例。如果您正苦于以下问题:C# RouteBase类的具体用法?C# RouteBase怎么用?C# RouteBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RouteBase类属于System.Web.Routing命名空间,在下文中一共展示了RouteBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例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);
}
示例4: RedirectRoute
public RedirectRoute(RouteBase sourceRoute, RouteBase targetRoute, bool permanent, Func<RequestContext, RouteValueDictionary> additionalRouteValues)
{
SourceRoute = sourceRoute;
TargetRoute = targetRoute;
Permanent = permanent;
AdditionalRouteValuesFunc = additionalRouteValues;
}
示例5: VirtualPathData
public VirtualPathData (RouteBase route, string virtualPath)
{
// arguments can be null.
Route = route;
VirtualPath = virtualPath;
DataTokens = new RouteValueDictionary ();
}
示例6: RouteData
public RouteData(RouteBase route, IRouteHandler routeHandler)
{
this._values = new RouteValueDictionary();
this._dataTokens = new RouteValueDictionary();
this.Route = route;
this.RouteHandler = routeHandler;
}
示例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);
}
}
示例8: RedirectRoute
public RedirectRoute(RouteBase sourceRoute, RouteBase targetRoute, bool permanent, RouteValueDictionary additionalRouteValues)
{
SourceRoute = sourceRoute;
TargetRoute = targetRoute;
Permanent = permanent;
AdditionalRouteValues = additionalRouteValues;
}
示例9: RouteData
public RouteData (RouteBase route, IRouteHandler routeHandler)
{
// arguments can be null.
Route = route;
RouteHandler = routeHandler;
DataTokens = new RouteValueDictionary ();
Values = new RouteValueDictionary ();
}
示例10: NormalizeRoute
public NormalizeRoute(RouteBase route, bool requireLowerCase, bool appendTrailingSlash)
: base(route)
{
if (route == null) {
throw new ArgumentNullException("route");
}
AppendTrailingSlash = appendTrailingSlash;
RequireLowerCase = requireLowerCase;
}
示例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;
}
示例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"]);
}
示例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();
}
示例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;
}
示例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;
}