public override int ReadContentAsBinHex(byte[] buffer, int index, int count)
{
// check arguments
if (buffer == null)
{
throw new ArgumentNullException(nameof(buffer));
}
if (count < 0)
{
throw new ArgumentOutOfRangeException(nameof(count));
}
if (index < 0)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
if (buffer.Length - index < count)
{
throw new ArgumentOutOfRangeException(nameof(count));
}
// if not the first call to ReadContentAsBinHex
if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
{
// and if we have a correct decoder
if (_incReadDecoder == _binHexDecoder)
{
// read more binary data
return ReadContentAsBinary(buffer, index, count);
}
}
// first call of ReadContentAsBinHex -> initialize (move to first text child (for elements) and initialize incremental read state)
else
{
if (_readState != ReadState.Interactive)
{
return 0;
}
if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary)
{
throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
}
if (!XmlReader.CanReadContentAs(_curNode.type))
{
throw CreateReadContentAsException(nameof(ReadContentAsBinHex));
}
if (!InitReadContentAsBinary())
{
return 0;
}
}
// setup binhex decoder (when in first ReadContentAsBinHex call or when mixed with ReadContentAsBase64)
InitBinHexDecoder();
// read binary data
return ReadContentAsBinary(buffer, index, count);
}