RouteUrlExpressionBuilder.TryParseRouteExpression(String, RouteValueDictionary, String) 方法
定义
将表达式分析为路由键和值的集合,还可以分析为路由名称。Parses an expression into a collection of route keys and values, and optionally into a route name.
public:
static bool TryParseRouteExpression(System::String ^ expression, System::Web::Routing::RouteValueDictionary ^ routeValues, [Runtime::InteropServices::Out] System::String ^ % routeName);
public static bool TryParseRouteExpression (string expression, System.Web.Routing.RouteValueDictionary routeValues, out string routeName);
static member TryParseRouteExpression : string * System.Web.Routing.RouteValueDictionary * string -> bool
Public Shared Function TryParseRouteExpression (expression As String, routeValues As RouteValueDictionary, ByRef routeName As String) As Boolean
参数
- expression
- String
标记中指定的表达式。The expression as specified in markup.
- routeValues
- RouteValueDictionary
路由键及其关联值的集合。The collection of route keys and their associated values.
- routeName
- String
此方法返回时,如果 expression 包含名为 RouteName 的路由键,此参数则包含一个表示路由名称的字符串。When this method returns, contains a string that represents the name of the route, if expression contains a route key named RouteName. 此参数未经初始化即被传递。This parameter is passed uninitialized.
返回
如果分析成功,则为 true;否则为 false。true if parsing was successful; otherwise, false.
注解
TryParseRouteExpression方法从表达式中去除前导空格和尾随空格,然后使用逗号作为分隔符将其拆分为键/值对。The TryParseRouteExpression method strips leading and trailing spaces from the expression, and then splits it into key/value pairs by using commas as delimiters. 如果找到名为的路由键 RouteName ,则该值传递回 routeName 参数而不是中 routeValues 。If the route key named RouteName is found, that value is passed back in the routeName parameter and not in routeValues. 否则, null 将返回 routeName 。Otherwise, null is returned for routeName. 前导空格和尾随空格还会从单个键和值中去除。Leading and trailing spaces are also stripped from individual keys and values.
TryParseRouteExpression false 如果表达式不由至少一个值为格式 键值 的键/值对组成 = ,且使用逗号分隔多个对,则方法返回。The TryParseRouteExpression method returns false if the expression is not composed of at least one key/value pair that is in the format key=value, and that uses commas to separate multiple pairs.