Ejemplo n.º 1
0
        public override int ReadContentAsBinHex(byte[] buffer, int index, int count)
        {
            if (this.ReadState != System.Xml.ReadState.Interactive)
            {
                return(0);
            }
            if (this.state != State.InReadBinary)
            {
                if (base.CanReadBinaryContent && !this.checkCharacters)
                {
                    this.readBinaryHelper = null;
                    this.state            = State.InReadBinary;
                    return(base.ReadContentAsBinHex(buffer, index, count));
                }
                this.readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(this.readBinaryHelper, this);
            }
            else if (this.readBinaryHelper == null)
            {
                return(base.ReadContentAsBinHex(buffer, index, count));
            }
            this.state = State.Interactive;
            int num = this.readBinaryHelper.ReadContentAsBinHex(buffer, index, count);

            this.state = State.InReadBinary;
            return(num);
        }
Ejemplo n.º 2
0
        public override int ReadElementContentAsBase64(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 (ReadState != ReadState.Interactive)
            {
                return(0);
            }

            if (_state != State.InReadBinary)
            {
                // forward ReadBase64Chunk calls into the base (wrapped) reader if possible, i.e. if it can read binary and we
                // should not check characters
                if (base.CanReadBinaryContent && (!_checkCharacters))
                {
                    _readBinaryHelper = null;
                    _state            = State.InReadBinary;
                    return(base.ReadElementContentAsBase64(buffer, index, count));
                }
                // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore whitespace
                else
                {
                    _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this);
                }
            }
            else
            {
                // forward calls into wrapped reader
                if (_readBinaryHelper == null)
                {
                    return(base.ReadElementContentAsBase64(buffer, index, count));
                }
            }

            // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper
            _state = State.Interactive;

            // call to the helper
            int readCount = _readBinaryHelper.ReadElementContentAsBase64(buffer, index, count);

            // turn on InReadBinary in again and return
            _state = State.InReadBinary;
            return(readCount);
        }
Ejemplo n.º 3
0
        public override async Task <int> ReadContentAsBase64Async(byte[] buffer, int index, int count)
        {
            if (ReadState != ReadState.Interactive)
            {
                return(0);
            }

            // init ReadContentAsBinaryHelper when called first time
            if (validationState != ValidatingReaderState.OnReadBinaryContent)
            {
                readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(readBinaryHelper, this);
                savedState       = validationState;
            }

            // restore original state in order to have a normal Read() behavior when called from readBinaryHelper
            validationState = savedState;

            // call to the helper
            int readCount = await readBinaryHelper.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false);

            // set OnReadBinaryContent state again and return
            savedState      = validationState;
            validationState = ValidatingReaderState.OnReadBinaryContent;
            return(readCount);
        }
        public override int ReadElementContentAsBinHex( byte[] buffer, int index, int count ) {
            if ( ReadState != ReadState.Interactive ) {
                return 0;
            }

            if ( state != State.InReadBinary ) {
                // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we 
                // should not check characters
                if ( base.CanReadBinaryContent && ( !checkCharacters ) ) {
                    readBinaryHelper = null;
                    state = State.InReadBinary;
                    return base.ReadElementContentAsBinHex( buffer, index, count );
                }
                // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces
                else {
                    readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset( readBinaryHelper, this );
                }
            }
            else { 
                // forward calls into wrapped reader 
                if ( readBinaryHelper == null ) {
                    return base.ReadElementContentAsBinHex( buffer, index, count );
                }
            }

            // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper
            state = State.Interactive;

            // call to the helper
            int readCount = readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);

            // turn on InReadBinary in again and return
            state = State.InReadBinary;
            return readCount;        
        }
Ejemplo n.º 5
0
        public override async Task <int> ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count)
        {
            if (ReadState != ReadState.Interactive)
            {
                return(0);
            }

            // init ReadContentAsBinaryHelper when called first time
            if (_validationState != ValidatingReaderState.OnReadBinaryContent)
            {
                _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this);
                _savedState       = _validationState;
            }

            // restore original state in order to have a normal Read() behavior when called from readBinaryHelper
            _validationState = _savedState;

            // call to the helper
            Debug.Assert(_readBinaryHelper != null);
            int readCount = await _readBinaryHelper.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false);

            // set OnReadBinaryContent state again and return
            _savedState      = _validationState;
            _validationState = ValidatingReaderState.OnReadBinaryContent;
            return(readCount);
        }
Ejemplo n.º 6
0
        public override async Task <int> ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count)
        {
            // check arguments
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (buffer.Length - index < count)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (ReadState != ReadState.Interactive)
            {
                return(0);
            }

            if (state != State.InReadBinary)
            {
                // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we
                // should not check characters
                if (base.CanReadBinaryContent && (!checkCharacters))
                {
                    readBinaryHelper = null;
                    state            = State.InReadBinary;
                    return(await base.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false));
                }
                // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces
                else
                {
                    readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(readBinaryHelper, this);
                }
            }
            else
            {
                // forward calls into wrapped reader
                if (readBinaryHelper == null)
                {
                    return(await base.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false));
                }
            }

            // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper
            state = State.Interactive;

            // call to the helper
            int readCount = await readBinaryHelper.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false);

            // turn on InReadBinary in again and return
            state = State.InReadBinary;
            return(readCount);
        }
// Static methods 
        internal static ReadContentAsBinaryHelper CreateOrReset( ReadContentAsBinaryHelper helper, XmlReader reader ) {
            if ( helper == null ) {
                return new ReadContentAsBinaryHelper( reader );
            }
            else {
                helper.Reset();
                return helper;
            }
        }
 internal static ReadContentAsBinaryHelper CreateOrReset(ReadContentAsBinaryHelper helper, XmlReader reader)
 {
     if (helper == null)
     {
         return(new ReadContentAsBinaryHelper(reader));
     }
     helper.Reset();
     return(helper);
 }
        public override Task <int> ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count)
        {
            ArgumentNullException.ThrowIfNull(buffer);
            if (index < 0 || (uint)count > buffer.Length - index)
            {
                throw new ArgumentOutOfRangeException(index < 0 ? nameof(index) : nameof(count));
            }

            if (ReadState != ReadState.Interactive)
            {
                return(Task.FromResult(0));
            }

            return(Core(buffer, index, count));

            async Task <int> Core(byte[] buffer, int index, int count)
            {
                if (_state != State.InReadBinary)
                {
                    // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we
                    // should not check characters
                    if (base.CanReadBinaryContent && (!_checkCharacters))
                    {
                        _readBinaryHelper = null;
                        _state            = State.InReadBinary;
                        return(await base.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false));
                    }
                    // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore whitespace
                    else
                    {
                        _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this);
                    }
                }
                else
                {
                    // forward calls into wrapped reader
                    if (_readBinaryHelper == null)
                    {
                        return(await base.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false));
                    }
                }

                // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper
                _state = State.Interactive;

                // call to the helper
                int readCount = await _readBinaryHelper.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false);

                // turn on InReadBinary in again and return
                _state = State.InReadBinary;
                return(readCount);
            }
        }
Ejemplo n.º 10
0
        public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
        {
            if (this.ReadState != System.Xml.ReadState.Interactive)
            {
                return(0);
            }
            if (this.parsingFunction != ParsingFunction.InReadBinaryContent)
            {
                this.readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(this.readBinaryHelper, this.outerReader);
            }
            this.parsingFunction = ParsingFunction.Read;
            int num = this.readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);

            this.parsingFunction = ParsingFunction.InReadBinaryContent;
            return(num);
        }
        public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
        {
            if (this.readState != System.Xml.ReadState.Interactive)
            {
                return(0);
            }
            if (!this.bInReadBinary)
            {
                this.readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(this.readBinaryHelper, this);
            }
            this.bInReadBinary = false;
            int num = this.readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);

            this.bInReadBinary = true;
            return(num);
        }
        public override async Task <int> ReadContentAsBinHexAsync(byte[] buffer, int index, int count)
        {
            if (ReadState != ReadState.Interactive)
            {
                return(0);
            }

            if (_state != State.InReadBinary)
            {
                // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we
                // should not check characters
                if (base.CanReadBinaryContent && (!_checkCharacters))
                {
                    _readBinaryHelper = null;
                    _state            = State.InReadBinary;
                    return(await base.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false));
                }
                // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore whitespace
                else
                {
                    _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this);
                }
            }
            else
            {
                // forward calls into wrapped reader
                if (_readBinaryHelper == null)
                {
                    return(await base.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false));
                }
            }

            // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper
            _state = State.Interactive;

            // call to the helper
            int readCount = await _readBinaryHelper.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false);

            // turn on InReadBinary in again and return
            _state = State.InReadBinary;
            return(readCount);
        }
Ejemplo n.º 13
0
        public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if ((buffer.Length - index) < count)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (this.ReadState != System.Xml.ReadState.Interactive)
            {
                return(0);
            }
            if (this.state != State.InReadBinary)
            {
                if (base.CanReadBinaryContent && !this.checkCharacters)
                {
                    this.readBinaryHelper = null;
                    this.state            = State.InReadBinary;
                    return(base.ReadElementContentAsBinHex(buffer, index, count));
                }
                this.readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(this.readBinaryHelper, this);
            }
            else if (this.readBinaryHelper == null)
            {
                return(base.ReadElementContentAsBinHex(buffer, index, count));
            }
            this.state = State.Interactive;
            int num = this.readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);

            this.state = State.InReadBinary;
            return(num);
        }
        public override int  ReadElementContentAsBinHex(byte[] buffer, int index, int count)
        {
            if (ReadState != ReadState.Interactive)
            {
                return(0);
            }

            // init ReadChunkHelper when called first time
            if (parsingFunction != ParsingFunction.InReadBinaryContent)
            {
                readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(readBinaryHelper, outerReader);
            }

            // set parsingFunction to Read state in order to have a normal Read() behavior when called from readBinaryHelper
            parsingFunction = ParsingFunction.Read;

            // call to the helper
            int readCount = readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);

            // setup parsingFunction
            parsingFunction = ParsingFunction.InReadBinaryContent;
            return(readCount);
        }
        public override async Task <int> ReadContentAsBase64Async(byte[] buffer, int index, int count)
        {
            if (ReadState != ReadState.Interactive)
            {
                return(0);
            }

            // init ReadChunkHelper if called the first time
            if (_parsingFunction != ParsingFunction.InReadBinaryContent)
            {
                _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, _outerReader);
            }

            // set parsingFunction to Read state in order to have a normal Read() behavior when called from readBinaryHelper
            _parsingFunction = ParsingFunction.Read;

            // call to the helper
            int readCount = await _readBinaryHelper.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false);

            // setup parsingFunction
            _parsingFunction = ParsingFunction.InReadBinaryContent;
            return(readCount);
        }
 public override int ReadContentAsBinHex(byte[] buffer, int index, int count)
 {
     if (this.ReadState != System.Xml.ReadState.Interactive)
     {
         return 0;
     }
     if (this.state != State.InReadBinary)
     {
         if (base.CanReadBinaryContent && !this.checkCharacters)
         {
             this.readBinaryHelper = null;
             this.state = State.InReadBinary;
             return base.ReadContentAsBinHex(buffer, index, count);
         }
         this.readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(this.readBinaryHelper, this);
     }
     else if (this.readBinaryHelper == null)
     {
         return base.ReadContentAsBinHex(buffer, index, count);
     }
     this.state = State.Interactive;
     int num = this.readBinaryHelper.ReadContentAsBinHex(buffer, index, count);
     this.state = State.InReadBinary;
     return num;
 }
 public override int ReadElementContentAsBase64(byte[] buffer, int index, int count)
 {
     if (this.ReadState != System.Xml.ReadState.Interactive)
     {
         return 0;
     }
     if (this.state != State.InReadBinary)
     {
         this.readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(this.readBinaryHelper, this);
         this.savedState = this.state;
     }
     this.state = this.savedState;
     int num = this.readBinaryHelper.ReadElementContentAsBase64(buffer, index, count);
     this.savedState = this.state;
     this.state = State.InReadBinary;
     return num;
 }
Ejemplo n.º 18
0
        public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
        {
            // check arguments
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (buffer.Length - index < count)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (ReadState != ReadState.Interactive)
            {
                return 0;
            }

            if (_state != State.InReadBinary)
            {
                // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we 
                // should not check characters
                if (base.CanReadBinaryContent && (!_checkCharacters))
                {
                    _readBinaryHelper = null;
                    _state = State.InReadBinary;
                    return base.ReadElementContentAsBinHex(buffer, index, count);
                }
                // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces
                else
                {
                    _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this);
                }
            }
            else
            {
                // forward calls into wrapped reader 
                if (_readBinaryHelper == null)
                {
                    return base.ReadElementContentAsBinHex(buffer, index, count);
                }
            }

            // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper
            _state = State.Interactive;

            // call to the helper
            int readCount = _readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);

            // turn on InReadBinary in again and return
            _state = State.InReadBinary;
            return readCount;
        }
        public override  int  ReadElementContentAsBinHex( byte[] buffer, int index, int count ) {
            if ( ReadState != ReadState.Interactive ) {
                return 0;
            }

            // init ReadChunkHelper when called first time
            if ( parsingFunction != ParsingFunction.InReadBinaryContent ) {
                readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset( readBinaryHelper, outerReader );
            }

            // set parsingFunction to Read state in order to have a normal Read() behavior when called from readBinaryHelper
            parsingFunction = ParsingFunction.Read;

            // call to the helper
            int readCount = readBinaryHelper.ReadElementContentAsBinHex( buffer, index, count );

            // setup parsingFunction 
            parsingFunction = ParsingFunction.InReadBinaryContent;
            return readCount;
        }
 public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
 {
     if (this.ReadState != System.Xml.ReadState.Interactive)
     {
         return 0;
     }
     if (this.validationState != ValidatingReaderState.OnReadBinaryContent)
     {
         this.readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(this.readBinaryHelper, this);
         this.savedState = this.validationState;
     }
     this.validationState = this.savedState;
     int num = this.readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);
     this.savedState = this.validationState;
     this.validationState = ValidatingReaderState.OnReadBinaryContent;
     return num;
 }
        public override  int  ReadContentAsBinHex( byte[] buffer, int index, int count ) {
            if (ReadState != ReadState.Interactive) {
                return 0;
            }

            if ( state != State.InReadBinary ) {
                // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we 
                // should not check characters
                if ( base.CanReadBinaryContent && ( !checkCharacters ) ) {
                    readBinaryHelper = null;
                    state = State.InReadBinary;
                    return base.ReadContentAsBinHex( buffer, index, count );
                }
                // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces
                else {
                    readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset( readBinaryHelper, this );
                }
            }
            else { 
                // forward calls into wrapped reader 
                if ( readBinaryHelper == null ) {
                    return base.ReadContentAsBinHex( buffer, index, count );
                }
            }

            // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper
            state = State.Interactive;

            // call to the helper
            int readCount = readBinaryHelper.ReadContentAsBinHex(buffer, index, count);

            // turn on InReadBinary in again and return
            state = State.InReadBinary;
            return readCount;        
        }
 public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
 {
     if (buffer == null)
     {
         throw new ArgumentNullException("buffer");
     }
     if (count < 0)
     {
         throw new ArgumentOutOfRangeException("count");
     }
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     if ((buffer.Length - index) < count)
     {
         throw new ArgumentOutOfRangeException("count");
     }
     if (this.ReadState != System.Xml.ReadState.Interactive)
     {
         return 0;
     }
     if (this.state != State.InReadBinary)
     {
         if (base.CanReadBinaryContent && !this.checkCharacters)
         {
             this.readBinaryHelper = null;
             this.state = State.InReadBinary;
             return base.ReadElementContentAsBinHex(buffer, index, count);
         }
         this.readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(this.readBinaryHelper, this);
     }
     else if (this.readBinaryHelper == null)
     {
         return base.ReadElementContentAsBinHex(buffer, index, count);
     }
     this.state = State.Interactive;
     int num = this.readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);
     this.state = State.InReadBinary;
     return num;
 }
        public override  int  ReadElementContentAsBinHex(byte[] buffer, int index, int count) {
            if (ReadState != ReadState.Interactive) {
                return 0;
            }

            // init ReadContentAsBinaryHelper when called first time
            if (validationState != ValidatingReaderState.OnReadBinaryContent) {
                readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(readBinaryHelper, this);
                savedState = validationState;
            }

            // restore original state in order to have a normal Read() behavior when called from readBinaryHelper
            validationState = savedState;

            // call to the helper
            int readCount = readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);

            // set OnReadBinaryContent state again and return
            savedState = validationState;
            validationState = ValidatingReaderState.OnReadBinaryContent;
            return readCount;
        }
Ejemplo n.º 24
0
        public override int ReadElementContentAsBinHex( byte[] buffer, int index, int count ) {
            if ( readState != ReadState.Interactive ) {
                return 0;
            }

            // init ReadContentAsBinaryHelper when called first time
            if ( !bInReadBinary ) {
                readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset( readBinaryHelper, this );
            }

            // turn off bInReadBinary in order to have a normal Read() behavior when called from readBinaryHelper
            bInReadBinary = false;

            // call to the helper
            int readCount = readBinaryHelper.ReadElementContentAsBinHex( buffer, index, count );

            // turn on bInReadBinary in again and return
            bInReadBinary = true;
            return readCount;
        }