/// <summary> /// Calculates the ResourceStringInformation based on the ODataRequest and maxProtocol version to determine if this i /// </summary> /// <param name="request">Request to calculate from</param> /// <param name="maxProtocolVersion">Max Protocol version of the server</param> /// <param name="expectedErrorMessage">Calculated Version Error information</param> /// <returns>boolean value of if a Error ResourceString Information was calculated or not</returns> public bool TryCalculateError(ODataRequest request, DataServiceProtocolVersion maxProtocolVersion, out ExpectedErrorMessage expectedErrorMessage) { ExceptionUtilities.CheckArgumentNotNull(request, "request"); expectedErrorMessage = null; DataServiceProtocolVersion dataServiceVersion = VersionHelper.ConvertToDataServiceProtocolVersion(request.GetHeaderValueIfExists(HttpHeaders.DataServiceVersion)); DataServiceProtocolVersion maxDataServiceVersion = VersionHelper.ConvertToDataServiceProtocolVersion(request.GetHeaderValueIfExists(HttpHeaders.MaxDataServiceVersion)); if (dataServiceVersion == DataServiceProtocolVersion.Unspecified) { dataServiceVersion = VersionHelper.CalculateDataServiceVersionIfNotSpecified(maxProtocolVersion, maxDataServiceVersion); } if (TryCalculateDataServiceVersionTooHighError(dataServiceVersion, maxProtocolVersion, out expectedErrorMessage)) { return(true); } string contentType = request.GetHeaderValueIfExists(HttpHeaders.ContentType); string acceptType = request.GetHeaderValueIfExists(HttpHeaders.Accept); if (contentType == null) { contentType = MimeTypes.Any; } if (acceptType == null) { acceptType = MimeTypes.Any; } // Do Uri processing first if (this.TryCalculateODataUriProcessingError(request, maxDataServiceVersion, maxProtocolVersion, acceptType, out expectedErrorMessage)) { return(true); } // Now check metadata of what the request should look like, will it cause a version bump greater than the DSV EntitySet expectedEntitySet = null; if (request.Uri.TryGetExpectedEntitySet(out expectedEntitySet)) { DataServiceProtocolVersion entitySetUriVersion = CalculateEntitySetUriSegmentRequestVersion(request, expectedEntitySet, maxProtocolVersion, maxDataServiceVersion, contentType); if (TryCalculateVersionError(entitySetUriVersion, dataServiceVersion, maxProtocolVersion, out expectedErrorMessage)) { return(true); } } // First ensure that the version is greater than mpv if (maxProtocolVersion < dataServiceVersion) { expectedErrorMessage = new ExpectedErrorMessage(DataServiceRequestVersionMustBeLessThanMPV, dataServiceVersion.ConvertToHeaderFormat(), maxProtocolVersion.ConvertToHeaderFormat()); return(true); } // Now review the version of the payload and create the right errors if (this.TryCalculateODataResponseError(request, dataServiceVersion, maxDataServiceVersion, maxProtocolVersion, out expectedErrorMessage)) { return(true); } // Now check for any errors from reading the payload return(TryCalculateReaderError(request, dataServiceVersion, this.StringResourceVerifiers, this.MetadataResolver, out expectedErrorMessage)); }