Inheritance: IncrementalReadDecoder
 private void InitBase64Decoder()
 {
     if (this.base64Decoder == null)
     {
         this.base64Decoder = new Base64Decoder();
     }
     else
     {
         this.base64Decoder.Reset();
     }
     this.decoder = this.base64Decoder;
 }
 private void InitBase64Decoder()
 {
     if (base64Decoder == null)
     {
         base64Decoder = new Base64Decoder();
     }
     else
     {
         base64Decoder.Reset();
     }
     decoder = base64Decoder;
 }
Esempio n. 3
0
 private void InitBase64Decoder()
 {
     if (_base64Decoder == null)
     {
         _base64Decoder = new Base64Decoder();
     }
     else
     {
         _base64Decoder.Reset();
     }
     _decoder = _base64Decoder;
 }
 private void InitBase64Decoder()
 {
     if (this.base64Decoder == null)
     {
         this.base64Decoder = new Base64Decoder();
     }
     else
     {
         this.base64Decoder.Reset();
     }
     this.decoder = this.base64Decoder;
 }
        public override async Task <int> ReadContentAsBase64Async(byte[] buffer, int index, int count)
        {
            switch (_state)
            {
            case State.Initial:
            case State.EndOfFile:
            case State.Closed:
            case State.Error:
                return(0);

            case State.ClearNsAttributes:
            case State.PopNamespaceScope:
                switch (NodeType)
                {
                case XmlNodeType.Element:
                    throw CreateReadContentAsException("ReadContentAsBase64");

                case XmlNodeType.EndElement:
                    return(0);

                case XmlNodeType.Attribute:
                    if (_curNsAttr != -1 && reader.CanReadBinaryContent)
                    {
                        CheckBuffer(buffer, index, count);
                        if (count == 0)
                        {
                            return(0);
                        }
                        if (_nsIncReadOffset == 0)
                        {
                            // called first time on this ns attribute
                            if (_binDecoder != null && _binDecoder is Base64Decoder)
                            {
                                _binDecoder.Reset();
                            }
                            else
                            {
                                _binDecoder = new Base64Decoder();
                            }
                        }
                        if (_nsIncReadOffset == _curNode.value.Length)
                        {
                            return(0);
                        }
                        _binDecoder.SetNextOutputBuffer(buffer, index, count);
                        _nsIncReadOffset += _binDecoder.Decode(_curNode.value, _nsIncReadOffset, _curNode.value.Length - _nsIncReadOffset);
                        return(_binDecoder.DecodedCount);
                    }
                    goto case XmlNodeType.Text;

                case XmlNodeType.Text:
                    Debug.Assert(AttributeCount > 0);
                    return(await reader.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false));

                default:
                    Debug.Assert(false);
                    return(0);
                }

            case State.Interactive:
                _state = State.ReadContentAsBase64;
                goto case State.ReadContentAsBase64;

            case State.ReadContentAsBase64:
                int read = await reader.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false);

                if (read == 0)
                {
                    _state = State.Interactive;
                    ProcessNamespaces();
                }
                return(read);

            case State.ReadContentAsBinHex:
            case State.ReadElementContentAsBase64:
            case State.ReadElementContentAsBinHex:
                throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);

            default:
                Debug.Assert(false);
                return(0);
            }
        }
Esempio n. 6
0
        public override async Task<int> ReadContentAsBase64Async(byte[] buffer, int index, int count)
        {
            switch (_state)
            {
                case State.Initial:
                case State.EndOfFile:
                case State.Closed:
                case State.Error:
                    return 0;

                case State.ClearNsAttributes:
                case State.PopNamespaceScope:
                    switch (NodeType)
                    {
                        case XmlNodeType.Element:
                            throw CreateReadContentAsException("ReadContentAsBase64");
                        case XmlNodeType.EndElement:
                            return 0;
                        case XmlNodeType.Attribute:
                            if (_curNsAttr != -1 && reader.CanReadBinaryContent)
                            {
                                CheckBuffer(buffer, index, count);
                                if (count == 0)
                                {
                                    return 0;
                                }
                                if (_nsIncReadOffset == 0)
                                {
                                    // called first time on this ns attribute
                                    if (_binDecoder != null && _binDecoder is Base64Decoder)
                                    {
                                        _binDecoder.Reset();
                                    }
                                    else
                                    {
                                        _binDecoder = new Base64Decoder();
                                    }
                                }
                                if (_nsIncReadOffset == _curNode.value.Length)
                                {
                                    return 0;
                                }
                                _binDecoder.SetNextOutputBuffer(buffer, index, count);
                                _nsIncReadOffset += _binDecoder.Decode(_curNode.value, _nsIncReadOffset, _curNode.value.Length - _nsIncReadOffset);
                                return _binDecoder.DecodedCount;
                            }
                            goto case XmlNodeType.Text;
                        case XmlNodeType.Text:
                            Debug.Assert(AttributeCount > 0);
                            return await reader.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false);
                        default:
                            Debug.Assert(false);
                            return 0;
                    }

                case State.Interactive:
                    _state = State.ReadContentAsBase64;
                    goto case State.ReadContentAsBase64;

                case State.ReadContentAsBase64:
                    int read = await reader.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false);
                    if (read == 0)
                    {
                        _state = State.Interactive;
                        ProcessNamespaces();
                    }
                    return read;

                case State.ReadContentAsBinHex:
                case State.ReadElementContentAsBase64:
                case State.ReadElementContentAsBinHex:
                    throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);

                default:
                    Debug.Assert(false);
                    return 0;
            }
        }
 private void InitBase64Decoder()
 {
     if (_base64Decoder == null)
     {
         _base64Decoder = new Base64Decoder();
     }
     else
     {
         _base64Decoder.Reset();
     }
     _decoder = _base64Decoder;
 }
 private void InitBase64Decoder()
 {
     if (base64Decoder == null)
     {
         base64Decoder = new Base64Decoder();
     }
     else
     {
         base64Decoder.Reset();
     }
     decoder = base64Decoder;
 }