System.Xml.XmlTextReaderImpl.ReadElementContentAsBinHex C# (CSharp) Méthode

ReadElementContentAsBinHex() public méthode

public ReadElementContentAsBinHex ( byte buffer, int index, int count ) : int
buffer byte
index int
count int
Résultat int
        public override int ReadElementContentAsBinHex(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.InReadElementContentAsBinary)
            {
                // and if we have a correct decoder
                if (_incReadDecoder == _binHexDecoder)
                {
                    // read more binary data
                    return ReadElementContentAsBinary(buffer, index, count);
                }
            }
            // first call of ReadContentAsBinHex -> initialize
            else
            {
                if (_readState != ReadState.Interactive)
                {
                    return 0;
                }
                if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
                {
                    throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
                }
                if (_curNode.type != XmlNodeType.Element)
                {
                    throw CreateReadElementContentAsException(nameof(ReadElementContentAsBinHex));
                }
                if (!InitReadElementContentAsBinary())
                {
                    return 0;
                }
            }

            // setup binhex decoder (when in first ReadContentAsBinHex call or when mixed with ReadContentAsBase64)
            InitBinHexDecoder();

            // read binary data
            return ReadElementContentAsBinary(buffer, index, count);
        }

Usage Example

Exemple #1
0
 public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
 {
     return(_impl.ReadElementContentAsBinHex(buffer, index, count));
 }
XmlTextReaderImpl