Пример #1
0
        internal static ODataVersion GetDataServiceVersion(ODataMessage message, ODataVersion defaultVersion)
        {
            string header = message.GetHeader("DataServiceVersion");

            if (!string.IsNullOrEmpty(header))
            {
                return(ODataUtils.StringToODataVersion(header));
            }
            return(defaultVersion);
        }
Пример #2
0
        /// <summary>
        /// Sets the 'DataServiceVersion' HTTP header on the message based on the protocol version specified in the settings.
        /// </summary>
        /// <param name="message">The message to set the data service version header on.</param>
        /// <param name="settings">The <see cref="ODataMessageWriterSettings"/> determining the protocol version to use.</param>
        internal static void SetDataServiceVersion(ODataMessage message, ODataMessageWriterSettings settings)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(message != null, "message != null");
            Debug.Assert(settings != null, "settings != null");
            Debug.Assert(settings.Version.HasValue, "settings.Version.HasValue");

            string dataServiceVersionString = ODataUtils.ODataVersionToString(settings.Version.Value) + ";";

            message.SetHeader(ODataConstants.DataServiceVersionHeader, dataServiceVersionString);
        }
Пример #3
0
        /// <summary>
        /// Reads the DataServiceVersion header from the <paramref name="message"/> and parses it.
        /// If no DataServiceVersion header is found it sets the default version to be used for reading.
        /// </summary>
        /// <param name="message">The message to get the data service version header from.</param>
        /// <param name="defaultVersion">The default version to use if the header was not specified.</param>
        /// <returns>
        /// The <see cref="ODataVersion"/> retrieved from the DataServiceVersion header of the message.
        /// The default version if none is specified in the header.
        /// </returns>
        internal static ODataVersion GetDataServiceVersion(ODataMessage message, ODataVersion defaultVersion)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(message != null, "message != null");

            string originalHeaderValue = message.GetHeader(ODataConstants.DataServiceVersionHeader);
            string headerValue         = originalHeaderValue;

            return(string.IsNullOrEmpty(headerValue)
                ? defaultVersion
                : ODataUtils.StringToODataVersion(headerValue));
        }
Пример #4
0
        internal static void CheckVersionSupported(ODataVersion version, ODataMessageReaderSettings messageReaderSettings)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(messageReaderSettings != null, "messageReaderSettings != null");

            if (version > messageReaderSettings.MaxProtocolVersion)
            {
                throw new ODataException(Strings.ODataVersionChecker_MaxProtocolVersionExceeded(
                                             ODataUtils.ODataVersionToString(version),
                                             ODataUtils.ODataVersionToString(messageReaderSettings.MaxProtocolVersion)));
            }

#if DISABLE_V3
            if (version >= ODataVersion.V3)
            {
                throw new ODataException(Strings.ODataVersionChecker_ProtocolVersion3IsNotSupported);
            }
#endif
        }
Пример #5
0
        /// <summary>
        /// Check whether the EPM on the specified entity type is supported in the specified version.
        /// </summary>
        /// <param name="version">The version to check.</param>
        /// <param name="entityType">The entity type to check.</param>
        /// <param name="model">The model containing annotations for the entity type.</param>
        internal static void CheckEntityPropertyMapping(ODataVersion version, IEdmEntityType entityType, IEdmModel model)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(entityType != null, "entityType != null");
            Debug.Assert(model != null, "model != null");

            ODataEntityPropertyMappingCache epmCache = model.GetEpmCache(entityType);

            if (epmCache != null)
            {
                Debug.Assert(epmCache.EpmTargetTree != null, "If the EPM annotation is present the EPM tree must already be initialized.");
                if (version < epmCache.EpmTargetTree.MinimumODataProtocolVersion)
                {
                    throw new ODataException(
                              Strings.ODataVersionChecker_EpmVersionNotSupported(
                                  entityType.ODataFullName(),
                                  ODataUtils.ODataVersionToString(epmCache.EpmTargetTree.MinimumODataProtocolVersion),
                                  ODataUtils.ODataVersionToString(version)));
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Check whether CollectionValue is supported in the specified version.
        /// </summary>
        /// <param name="version">The version to check.</param>
        internal static void CheckCollectionValue(ODataVersion version)
        {
            DebugUtils.CheckNoExternalCallers();

            if (version < ODataVersion.V3)
            {
                throw new ODataException(Strings.ODataVersionChecker_CollectionNotSupported(ODataUtils.ODataVersionToString(version)));
            }
        }
Пример #7
0
        /// <summary>
        /// Check whether CollectionValue properties are supported in the specified version.
        /// </summary>
        /// <param name="version">The version to check.</param>
        /// <param name="propertyName">The name of the property which holds the collection.</param>
        internal static void CheckCollectionValueProperties(ODataVersion version, string propertyName)
        {
            DebugUtils.CheckNoExternalCallers();

            if (version < ODataVersion.V3)
            {
                throw new ODataException(Strings.ODataVersionChecker_CollectionPropertiesNotSupported(propertyName, ODataUtils.ODataVersionToString(version)));
            }
        }
Пример #8
0
        /// <summary>
        /// Check whether the spatial value is supported in the specified version.
        /// </summary>
        /// <param name="version">The version to check.</param>
        internal static void CheckSpatialValue(ODataVersion version)
        {
            DebugUtils.CheckNoExternalCallers();

            if (version < ODataVersion.V3)
            {
                throw new ODataException(Strings.ODataVersionChecker_GeographyAndGeometryNotSupported(ODataUtils.ODataVersionToString(version)));
            }
        }
Пример #9
0
        internal static void SetDataServiceVersion(ODataMessage message, ODataMessageWriterSettings settings)
        {
            string headerValue = ODataUtils.ODataVersionToString(settings.Version.Value) + ";";

            message.SetHeader("DataServiceVersion", headerValue);
        }
Пример #10
0
 internal static void CheckNextLink(ODataVersion version)
 {
     if (version < ODataVersion.V2)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_NextLinkNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Пример #11
0
 internal static void CheckCustomTypeScheme(ODataVersion version)
 {
     if (version > ODataVersion.V2)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_PropertyNotSupportedForODataVersionGreaterThanX("TypeScheme", ODataUtils.ODataVersionToString(ODataVersion.V2)));
     }
 }
Пример #12
0
 internal static void CheckCollectionValueProperties(ODataVersion version, string propertyName)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_CollectionPropertiesNotSupported(propertyName, ODataUtils.ODataVersionToString(version)));
     }
 }
Пример #13
0
 internal static void CheckStreamReferenceProperty(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_StreamPropertiesNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Пример #14
0
 internal static void CheckVersionSupported(ODataVersion version, ODataMessageReaderSettings messageReaderSettings)
 {
     if (version > messageReaderSettings.MaxProtocolVersion)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_MaxProtocolVersionExceeded(ODataUtils.ODataVersionToString(version), ODataUtils.ODataVersionToString(messageReaderSettings.MaxProtocolVersion)));
     }
 }
Пример #15
0
 internal static void CheckSpatialValue(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_GeographyAndGeometryNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Пример #16
0
 internal static void CheckAssociationLinks(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_AssociationLinksNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Пример #17
0
 internal static void CheckParameterPayload(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_ParameterPayloadNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Пример #18
0
        /// <summary>
        /// Check whether the next link feature is supported in the specified version.
        /// </summary>
        /// <param name="version">The version to check.</param>
        internal static void CheckNextLink(ODataVersion version)
        {
            DebugUtils.CheckNoExternalCallers();

            if (version < ODataVersion.V2)
            {
                throw new ODataException(Strings.ODataVersionChecker_NextLinkNotSupported(ODataUtils.ODataVersionToString(version)));
            }
        }
Пример #19
0
        /// <summary>
        /// Check whether the custom Data Namespace feature is supported in the specified version.
        /// </summary>
        /// <param name="version">The version to check.</param>
        internal static void CheckCustomDataNamespace(ODataVersion version)
        {
            DebugUtils.CheckNoExternalCallers();

            if (version > ODataVersion.V2)
            {
                throw new ODataException(Strings.ODataVersionChecker_PropertyNotSupportedForODataVersionGreaterThanX("DataNamespace", ODataUtils.ODataVersionToString(ODataVersion.V2)));
            }
        }
Пример #20
0
        /// <summary>
        /// Check whether the named streams feature is supported in the specified version.
        /// </summary>
        /// <param name="version">The version to check.</param>
        internal static void CheckStreamReferenceProperty(ODataVersion version)
        {
            DebugUtils.CheckNoExternalCallers();

            if (version < ODataVersion.V3)
            {
                throw new ODataException(Strings.ODataVersionChecker_StreamPropertiesNotSupported(ODataUtils.ODataVersionToString(version)));
            }
        }
Пример #21
0
        /// <summary>
        /// Check whether parameters in the payload are supported in the specified version.
        /// </summary>
        /// <param name="version">The version to check.</param>
        internal static void CheckParameterPayload(ODataVersion version)
        {
            DebugUtils.CheckNoExternalCallers();

            if (version < ODataVersion.V3)
            {
                throw new ODataException(Strings.ODataVersionChecker_ParameterPayloadNotSupported(ODataUtils.ODataVersionToString(version)));
            }
        }
Пример #22
0
 internal static void CheckCollectionValue(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_CollectionNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Пример #23
0
        internal static void CheckEntityPropertyMapping(ODataVersion version, IEdmEntityType entityType, IEdmModel model)
        {
            ODataEntityPropertyMappingCache epmCache = model.GetEpmCache(entityType);

            if ((epmCache != null) && (version < epmCache.EpmTargetTree.MinimumODataProtocolVersion))
            {
                throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_EpmVersionNotSupported(entityType.ODataFullName(), ODataUtils.ODataVersionToString(epmCache.EpmTargetTree.MinimumODataProtocolVersion), ODataUtils.ODataVersionToString(version)));
            }
        }