Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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
        }
Ejemplo n.º 3
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)));
                }
            }
        }
Ejemplo n.º 4
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)));
            }
        }
Ejemplo n.º 5
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)));
            }
        }
Ejemplo n.º 6
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)));
            }
        }
Ejemplo n.º 7
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)));
     }
 }
Ejemplo n.º 8
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)));
            }
        }
Ejemplo n.º 9
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)));
            }
        }
Ejemplo n.º 10
0
 internal static void CheckSpatialValue(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_GeographyAndGeometryNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Ejemplo n.º 11
0
 internal static void CheckAssociationLinks(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_AssociationLinksNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Ejemplo n.º 12
0
 internal static void CheckParameterPayload(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_ParameterPayloadNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Ejemplo n.º 13
0
 internal static void CheckNextLink(ODataVersion version)
 {
     if (version < ODataVersion.V2)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_NextLinkNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Ejemplo n.º 14
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)));
            }
        }
Ejemplo n.º 15
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)));
     }
 }
Ejemplo n.º 16
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)));
            }
        }
Ejemplo n.º 17
0
 internal static void CheckStreamReferenceProperty(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_StreamPropertiesNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
Ejemplo n.º 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)));
            }
        }
Ejemplo n.º 19
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)));
     }
 }
Ejemplo n.º 20
0
        internal static void SetDataServiceVersion(ODataMessage message, ODataMessageWriterSettings settings)
        {
            string headerValue = ODataUtils.ODataVersionToString(settings.Version.Value) + ";";

            message.SetHeader("DataServiceVersion", headerValue);
        }
Ejemplo n.º 21
0
 internal static void CheckCollectionValue(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_CollectionNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }