Esempio n. 1
0
        private DataServiceProtocolVersion CalculateExpectedClientMinRequestVersion(ODataUri odataUri, out ExpectedClientErrorBaseline errorIfTooLow)
        {
            ExceptionUtilities.CheckArgumentNotNull(odataUri, "odataUri");

            DataServiceProtocolVersion expectedVersion = DataServiceProtocolVersion.V4;

            errorIfTooLow = null;

            // Uri specific processing
            if (odataUri.HasAnyOrAllInFilter())
            {
                expectedVersion = VersionHelper.IncreaseVersionIfRequired(expectedVersion, DataServiceProtocolVersion.V4);
                string anyOrAll = string.Empty;

                if (odataUri.Filter.Contains("/any("))
                {
                    anyOrAll = "Any";
                }
                else
                {
                    anyOrAll = "All";
                }

                var errorInformation = new ExpectedErrorMessage("ALinq_MethodNotSupportedForMaxDataServiceVersionLessThanX", anyOrAll, expectedVersion.ConvertToHeaderFormat());
                errorIfTooLow = new ExpectedClientErrorBaseline(typeof(NotSupportedException), false, errorInformation);
            }

            if (odataUri.HasSignificantTypeSegmentInPath())
            {
                // TODO: this seems like it should be inferred from the query, not the uri
                expectedVersion = VersionHelper.IncreaseVersionIfRequired(expectedVersion, DataServiceProtocolVersion.V4);
                var errorInformation = new ExpectedErrorMessage("ALinq_MethodNotSupportedForMaxDataServiceVersionLessThanX", "OfType", expectedVersion.ConvertToHeaderFormat());
                errorIfTooLow = new ExpectedClientErrorBaseline(typeof(NotSupportedException), false, errorInformation);
            }
            else if (odataUri.HasTypeSegmentInExpandOrSelect())
            {
                // TODO: this seems like it should be inferred from the query, not the uri
                expectedVersion = VersionHelper.IncreaseVersionIfRequired(expectedVersion, DataServiceProtocolVersion.V4);
                var errorInformation = new ExpectedErrorMessage("ALinq_TypeAsNotSupportedForMaxDataServiceVersionLessThan3");
                errorIfTooLow = new ExpectedClientErrorBaseline(typeof(NotSupportedException), false, errorInformation);
            }

            return(expectedVersion);
        }