Пример #1
0
        public static object GetParameterValue(this IRoute route, HttpListenerRequest request, Type expectedType, string parameterName, ParameterLocation parameterLocation)
        {
            switch (parameterLocation)
            {
            case ParameterLocation.Query:
                return(route.GetQueryParameterValue(parameterName, request.RawUrl, expectedType));

            case ParameterLocation.Route:
                return(route.GetRouteParameterValue(parameterName, request.RawUrl, expectedType));

            case ParameterLocation.Header:
                return(route.GetHeaderParameterValue(parameterName, request.Headers, expectedType));

            default:
                throw new ArgumentOutOfRangeException("parameterLocation");
            }
        }