/// <summary> /// 从请求中解析出路由值 /// </summary> /// <param name="request">请求数据</param> /// <returns>路由值</returns> public IReadOnlyDictionary <string, string> GetRouteValues(RouteRequestData request) { if (Scheme != null && stringComparer.Equals(Scheme, request.Scheme) == false) { return(null); } var routeValues = new Dictionary <string, string>(stringComparer); if (HostTemplate != null) { var values = HostTemplate.GetRouteValues(request.Host); if (values == null) { return(null); } foreach (var pair in values) { routeValues.Add(pair.key, pair.value); } } { var values = PathTemplate.GetRouteValues(request.Path); if (values == null) { return(null); } foreach (var pair in values) { routeValues.Add(pair.Key, pair.Value); } } if (QueryStringTemplate != null) { var values = QueryStringTemplate.GetRouteValues(request.Path); if (values == null) { return(null); } foreach (var pair in values) { routeValues.Add(pair.Key, pair.Value); } } return(routeValues); }