System.Xml.XmlReader.CreateReadContentAsException C# (CSharp) Method

CreateReadContentAsException() private method

private CreateReadContentAsException ( string methodName ) : Exception
methodName string
return System.Exception
        internal Exception CreateReadContentAsException(string methodName)
        {
            return CreateReadContentAsException(methodName, NodeType, this as IXmlLineInfo);
        }

Same methods

XmlReader::CreateReadContentAsException ( string methodName, System.Xml.XmlNodeType nodeType, IXmlLineInfo lineInfo ) : Exception

Usage Example

        internal int ReadContentAsBase64(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));
            }

            switch (_state)
            {
            case State.None:
                if (!_reader.CanReadContentAs())
                {
                    throw _reader.CreateReadContentAsException(nameof(ReadContentAsBase64));
                }
                if (!Init())
                {
                    return(0);
                }
                break;

            case State.InReadContent:
                // if we have a correct decoder, go read
                if (_decoder == _base64Decoder)
                {
                    // read more binary data
                    return(ReadContentAsBinary(buffer, index, count));
                }
                break;

            case State.InReadElementContent:
                throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);

            default:
                Debug.Fail($"Unexpected state {_state}");
                return(0);
            }

            Debug.Assert(_state == State.InReadContent);

            // setup base64 decoder
            InitBase64Decoder();

            // read more binary data
            return(ReadContentAsBinary(buffer, index, count));
        }
All Usage Examples Of System.Xml.XmlReader::CreateReadContentAsException