本文整理汇总了C#中RouteDirection.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# RouteDirection.Equals方法的具体用法?C# RouteDirection.Equals怎么用?C# RouteDirection.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteDirection
的用法示例。
在下文中一共展示了RouteDirection.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Match
protected override bool Match(
HttpContextBase httpContext,
Route route,
string parameterName,
RouteValueDictionary values,
RouteDirection routeDirection)
{
bool matches;
if (routeDirection.Equals(RouteDirection.IncomingRequest))
{
var formMethod = httpContext.Request.Form["_method"];
if (formMethod == null)
{
matches = false;
}
else
{
matches = base.Match(httpContext, route, parameterName, values, routeDirection);
}
}
else
{
// Don't try to generate any URLs for this route; you need to use
// a form value instead
matches = false;
}
return matches;
}
示例2: Match
public static bool Match(IReadOnlyDictionary<string, IRouteConstraint> constraints,
IDictionary<string, object> routeValues,
HttpContext httpContext,
IRouter route,
RouteDirection routeDirection,
ILogger logger)
{
if (routeValues == null)
{
throw new ArgumentNullException(nameof(routeValues));
}
if (httpContext == null)
{
throw new ArgumentNullException(nameof(httpContext));
}
if (route == null)
{
throw new ArgumentNullException(nameof(route));
}
if (logger == null)
{
throw new ArgumentNullException(nameof(logger));
}
if (constraints == null)
{
return true;
}
foreach (var kvp in constraints)
{
var constraint = kvp.Value;
if (!constraint.Match(httpContext, route, kvp.Key, routeValues, routeDirection))
{
if (routeDirection.Equals(RouteDirection.IncomingRequest))
{
object routeValue;
routeValues.TryGetValue(kvp.Key, out routeValue);
logger.LogVerbose(
"Route value '{RouteValue}' with key '{RouteKey}' did not match " +
"the constraint '{RouteConstraint}'.",
routeValue,
kvp.Key,
kvp.Value);
}
return false;
}
}
return true;
}
示例3: Match
public static bool Match(
IDictionary<string, IRouteConstraint> constraints,
RouteValueDictionary routeValues,
HttpContext httpContext,
IRouter route,
RouteDirection routeDirection,
ILogger logger)
{
if (routeValues == null)
{
throw new ArgumentNullException(nameof(routeValues));
}
if (httpContext == null)
{
throw new ArgumentNullException(nameof(httpContext));
}
if (route == null)
{
throw new ArgumentNullException(nameof(route));
}
if (logger == null)
{
throw new ArgumentNullException(nameof(logger));
}
if (constraints == null)
{
return true;
}
foreach (var kvp in constraints)
{
var constraint = kvp.Value;
if (!constraint.Match(httpContext, route, kvp.Key, routeValues, routeDirection))
{
if (routeDirection.Equals(RouteDirection.IncomingRequest))
{
object routeValue;
routeValues.TryGetValue(kvp.Key, out routeValue);
logger.RouteValueDoesNotMatchConstraint(routeValue, kvp.Key, kvp.Value);
}
return false;
}
}
return true;
}