Exemplo n.º 1
0
        public bool Match(System.Net.Http.HttpRequestMessage request,
                          IHttpRoute route, string parameterName,
                          IDictionary <string, object> values,
                          HttpRouteDirection routeDirection)
        {
            object value;

            if (values.TryGetValue(parameterName, out value) && value != null)
            {
                return(AllowedVersion.Equals(value.ToString().ToLowerInvariant()));
            }
            return(false);
        }
Exemplo n.º 2
0
        public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary <string, object> values, HttpRouteDirection routeDirection)
        {
            object value;

            if (values != null && values.TryGetValue(parameterName, out value) && value != null)
            {
                if (!AllowedVersion.Equals(value.ToString().ToLowerInvariant()))
                {
                    const HttpStatusCode code = (HttpStatusCode)(int)ResponseCode.NotFound; //we only use a subset of codes
                    throw new HttpResponseException(request.CreateErrorResponse(code, string.Format("The version {0} is not supported.It must be v1.", value, CultureInfo.InvariantCulture)));
                }
            }

            return(true);
        }