System.Xml.XmlBaseWriter.WriteBase64AsyncImpl C# (CSharp) Méthode

WriteBase64AsyncImpl() private méthode

private WriteBase64AsyncImpl ( byte buffer, int offset, int count ) : System.Threading.Tasks.Task
buffer byte
offset int
count int
Résultat System.Threading.Tasks.Task
        private async Task WriteBase64AsyncImpl(byte[] buffer, int offset, int count)
        {
            if (count > 0)
            {
                if (_trailByteCount > 0)
                {
                    while (_trailByteCount < 3 && count > 0)
                    {
                        _trailBytes[_trailByteCount++] = buffer[offset++];
                        count--;
                    }
                }

                int totalByteCount = _trailByteCount + count;
                int actualByteCount = totalByteCount - (totalByteCount % 3);

                if (_trailBytes == null)
                {
                    _trailBytes = new byte[3];
                }

                if (actualByteCount >= 3)
                {
                    if (_attributeValue != null)
                    {
                        WriteAttributeText(XmlConverter.Base64Encoding.GetString(_trailBytes, 0, _trailByteCount));
                        WriteAttributeText(XmlConverter.Base64Encoding.GetString(buffer, offset, actualByteCount - _trailByteCount));
                    }
                    if (!_isXmlnsAttribute)
                    {
                        await StartContentAsync().ConfigureAwait(false);
                        await _writer.WriteBase64TextAsync(_trailBytes, _trailByteCount, buffer, offset, actualByteCount - _trailByteCount).ConfigureAwait(false);
                        EndContent();
                    }
                    _trailByteCount = (totalByteCount - actualByteCount);
                    if (_trailByteCount > 0)
                    {
                        int trailOffset = offset + count - _trailByteCount;
                        for (int i = 0; i < _trailByteCount; i++)
                            _trailBytes[i] = buffer[trailOffset++];
                    }
                }
                else
                {
                    Buffer.BlockCopy(buffer, offset, _trailBytes, _trailByteCount, count);
                    _trailByteCount += count;
                }
            }
        }