internal static ODataVersion GetDataServiceVersion(ODataMessage message, ODataVersion defaultVersion) { string header = message.GetHeader("DataServiceVersion"); if (!string.IsNullOrEmpty(header)) { return(ODataUtils.StringToODataVersion(header)); } return(defaultVersion); }
/// <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); }
/// <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)); }
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 }
/// <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))); } } }
/// <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))); } }
/// <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))); } }
/// <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))); } }
internal static void SetDataServiceVersion(ODataMessage message, ODataMessageWriterSettings settings) { string headerValue = ODataUtils.ODataVersionToString(settings.Version.Value) + ";"; message.SetHeader("DataServiceVersion", headerValue); }
internal static void CheckNextLink(ODataVersion version) { if (version < ODataVersion.V2) { throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_NextLinkNotSupported(ODataUtils.ODataVersionToString(version))); } }
internal static void CheckCustomTypeScheme(ODataVersion version) { if (version > ODataVersion.V2) { throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_PropertyNotSupportedForODataVersionGreaterThanX("TypeScheme", ODataUtils.ODataVersionToString(ODataVersion.V2))); } }
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))); } }
internal static void CheckStreamReferenceProperty(ODataVersion version) { if (version < ODataVersion.V3) { throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_StreamPropertiesNotSupported(ODataUtils.ODataVersionToString(version))); } }
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))); } }
internal static void CheckSpatialValue(ODataVersion version) { if (version < ODataVersion.V3) { throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_GeographyAndGeometryNotSupported(ODataUtils.ODataVersionToString(version))); } }
internal static void CheckAssociationLinks(ODataVersion version) { if (version < ODataVersion.V3) { throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_AssociationLinksNotSupported(ODataUtils.ODataVersionToString(version))); } }
internal static void CheckParameterPayload(ODataVersion version) { if (version < ODataVersion.V3) { throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_ParameterPayloadNotSupported(ODataUtils.ODataVersionToString(version))); } }
/// <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))); } }
/// <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))); } }
/// <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))); } }
/// <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))); } }
internal static void CheckCollectionValue(ODataVersion version) { if (version < ODataVersion.V3) { throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_CollectionNotSupported(ODataUtils.ODataVersionToString(version))); } }
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))); } }