예제 #1
0
        private string GetHttpMethodFromParameter(ServiceAttributeParameterInfo parameter)
        {
            var httpMethod = parameter.Value.ToUpperInvariant();

            if (!s_httpMethods.Contains(httpMethod))
            {
                AddValidationError(new ServiceDefinitionError($"Unsupported HTTP method '{httpMethod}'.", parameter.GetPart(ServicePartKind.Value)?.Position));
                return(null);
            }

            return(httpMethod);
        }
예제 #2
0
        private protected HttpStatusCode?TryParseStatusCodeInteger(ServiceAttributeParameterInfo parameter)
        {
            int.TryParse(parameter.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var valueAsInteger);
            if (valueAsInteger < 200 || valueAsInteger >= 599)
            {
                AddValidationError(new ServiceDefinitionError($"'{parameter.Name}' parameter must be an integer between 200 and 599.", parameter.GetPart(ServicePartKind.Value)?.Position));
                return(null);
            }

            return((HttpStatusCode)valueAsInteger);
        }