/// <inheritdoc /> public async Task <int> ReadAsync(IWireStreamReaderStrategyAsync source) { //Read the key from the stream. TKeyType key = await KeyTypeSerializerStrategy .ReadAsync(typeHandlingFlags.HasFlag(InformationHandlingFlags.DontConsumeRead)?source.WithOnlyPeekingAsync() : source) .ConfigureAwait(false); return(GenericMath.Convert <TKeyType, int>(key)); }
/// <inheritdoc /> public int Read(IWireStreamReaderStrategy source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } //Read the key from the stream. TKeyType key = KeyTypeSerializerStrategy .Read(typeHandlingFlags.HasFlag(InformationHandlingFlags.DontConsumeRead) ? source.WithOnlyPeeking() : source); return(GenericMath.Convert <TKeyType, int>(key)); }
/// <inheritdoc /> public void Write(int value, IWireStreamWriterStrategy dest) { if (dest == null) { throw new ArgumentNullException(nameof(dest)); } //If the key shouldn't be written then we avoid writing it //It may be that the data is needed to be left in the stream to indicate //something about the type later down the line. if (!typeHandlingFlags.HasFlag(InformationHandlingFlags.DontWrite)) { KeyTypeSerializerStrategy.Write(GenericMath.Convert <int, TKeyType>(value), dest); } }