/// <summary>
        /// Validates that the parsed context URI from the payload is consistent with the expected
        /// collection item type when reading collection payloads.
        /// </summary>
        /// <param name="contextUriParseResult">The parse result of the context URI from the payload.</param>
        /// <param name="expectedItemTypeReference">The expected item type of the collection items.</param>
        /// <returns>The actual item type of the collection items.</returns>
        internal static IEdmTypeReference ValidateCollectionContextUriAndGetPayloadItemTypeReference(
            ODataJsonLightContextUriParseResult contextUriParseResult,
            IEdmTypeReference expectedItemTypeReference)
        {
            if (contextUriParseResult == null || contextUriParseResult.EdmType == null)
            {
                return expectedItemTypeReference;
            }

            Debug.Assert(contextUriParseResult.EdmType is IEdmCollectionType, "contextUriParseResult.EdmType is IEdmCollectionType");
            IEdmCollectionType actualCollectionType = (IEdmCollectionType)contextUriParseResult.EdmType;
            if (expectedItemTypeReference != null)
            {
                // We allow co-variance in collection types (e.g., expecting the item type of Geography from a payload of Collection(GeographyPoint).
                if (!expectedItemTypeReference.IsAssignableFrom(actualCollectionType.ElementType))
                {
                    throw new ODataException(OData.Core.Strings.ReaderValidationUtils_ContextUriDoesNotReferTypeAssignableToExpectedType(
                        UriUtils.UriToString(contextUriParseResult.ContextUri),
                        actualCollectionType.ElementType.ODataFullName(),
                        expectedItemTypeReference.ODataFullName()));
                }
            }

            return actualCollectionType.ElementType;
        }