示例#1
0
        internal static HttpStatusCode GetExpectedStatusCode(ODataUri uri, IODataUriEvaluator evaluator)
        {
            bool specialStatusCodeIfNull = false;

            specialStatusCodeIfNull |= uri.IsNamedStream();
            specialStatusCodeIfNull |= uri.IsMediaResource();
            specialStatusCodeIfNull |= uri.IsEntity();
            specialStatusCodeIfNull |= uri.IsEntityReferenceLink();
            specialStatusCodeIfNull |= uri.IsPropertyValue();

            bool uriIsValue = uri.IsNamedStream() || uri.IsMediaResource();

            // For an action it is evaluated specially via the actionresponse verifier, skip eval here
            if (!uri.IsAction() && specialStatusCodeIfNull && evaluator.Evaluate(uri).IsNull)
            {
                if (uriIsValue)
                {
                    return(HttpStatusCode.NoContent);
                }
                else
                {
                    return(HttpStatusCode.NotFound);
                }
            }

            return(HttpStatusCode.OK);
        }
        internal static HttpStatusCode GetExpectedStatusCode(ODataUri uri, IODataUriEvaluator evaluator)
        {
            bool specialStatusCodeIfNull = false;

            specialStatusCodeIfNull |= uri.IsNamedStream();
            specialStatusCodeIfNull |= uri.IsMediaResource();
            specialStatusCodeIfNull |= uri.IsEntity();
            specialStatusCodeIfNull |= uri.IsEntityReferenceLink();
            specialStatusCodeIfNull |= uri.IsPropertyValue();
            
            bool uriIsValue = uri.IsNamedStream() || uri.IsMediaResource();

            // For an action it is evaluated specially via the actionresponse verifier, skip eval here
            if (!uri.IsAction() && specialStatusCodeIfNull && evaluator.Evaluate(uri).IsNull)
            {
                if (uriIsValue)
                {
                    return HttpStatusCode.NoContent;
                }
                else
                {
                    return HttpStatusCode.NotFound;
                }
            }

            return HttpStatusCode.OK;
        }
 /// <summary>
 /// Processes the given uri and produces an expected value according to the conventions of an OData server implementation
 /// </summary>
 /// <param name="evaluator">The evaluator</param>
 /// <param name="uri">The uri to process</param>
 /// <returns>The value resulting from processing the uri</returns>
 public static QueryValue Evaluate(this IODataUriEvaluator evaluator, ODataUri uri)
 {
     ExceptionUtilities.CheckArgumentNotNull(evaluator, "evaluator");
     return(evaluator.Evaluate(uri, true, true));
 }