src/Simple.OData.Client.Core/Adapter/ODataAdapterFactory.cs
/// <summary>
/// Returns a collection of supported protocol versions.
/// </summary>
/// <param name="response">HTTP response message with schema information</param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
Returns a collection of supported protocol versions.
Returns a collection of supported protocol versions .
protected async Task<IEnumerable<string>> GetSupportedProtocolVersionsAsync(HttpResponseMessage response)
	{
		if (response.Headers.TryGetValues(HttpLiteral.DataServiceVersion, out var headerValues) ||
			response.Headers.TryGetValues(HttpLiteral.ODataVersion, out headerValues))
		{
			return headerValues.SelectMany(x => x.Split(';')).Where(x => x.Length > 0);
		}
		else
		{
			try
			{
				var metadataString = await response
					.Content
					.ReadAsStringAsync()
					.ConfigureAwait(false);
				var protocolVersion = GetMetadataProtocolVersion(metadataString);
				return new[] { protocolVersion };
			}
			catch (Exception)
			{
				throw new InvalidOperationException("Unable to identify OData protocol version.");
			}
		}
	}
protected async Task < IEnumerable < string > > GetSupportedProtocolVersionsAsync ( HttpResponseMessage response ) { if ( response . Headers . TryGetValues ( HttpLiteral . DataServiceVersion , out var headerValues ) || response . Headers . TryGetValues ( HttpLiteral . ODataVersion , out headerValues ) ) { return headerValues . SelectMany ( x => x . Split ( ' ' ) ) . Where ( x => x . Length > 0 ) ; } else { try { var metadataString = await response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ; var protocolVersion = GetMetadataProtocolVersion ( metadataString ) ; return new [ ] { protocolVersion } ; } catch ( Exception ) { throw new InvalidOperationException ( " " ) ; } } }
Returns a collection of supported protocol versions.
Returns a collection of supported protocol versions .
None
None
response
HttpResponseMessage
HTTP response message with schema information
HTTP response message with schema information