System.Text.Decoder.Convert C# (CSharp) Méthode

Convert() private méthode

private Convert ( byte bytes, int byteIndex, int byteCount, char chars, int charIndex, int charCount, bool flush, int &bytesUsed, int &charsUsed, bool &completed ) : void
bytes byte
byteIndex int
byteCount int
chars char
charIndex int
charCount int
flush bool
bytesUsed int
charsUsed int
completed bool
Résultat void
        public virtual void Convert(byte[] bytes, int byteIndex, int byteCount,
                                      char[] chars, int charIndex, int charCount, bool flush,
                                      out int bytesUsed, out int charsUsed, out bool completed)
        {
            // Validate parameters
            if (bytes == null || chars == null)
                throw new ArgumentNullException((bytes == null ? "bytes" : "chars"),
                      Environment.GetResourceString("ArgumentNull_Array"));

            if (byteIndex < 0 || byteCount < 0)
                throw new ArgumentOutOfRangeException((byteIndex<0 ? "byteIndex" : "byteCount"),
                      Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));

            if (charIndex < 0 || charCount < 0)
                throw new ArgumentOutOfRangeException((charIndex<0 ? "charIndex" : "charCount"),
                      Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));

            if (bytes.Length - byteIndex < byteCount)
                throw new ArgumentOutOfRangeException("bytes",
                      Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"));

            if (chars.Length - charIndex < charCount)
                throw new ArgumentOutOfRangeException("chars",
                      Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"));

            bytesUsed = byteCount;

            // Its easy to do if it won't overrun our buffer.
            while (bytesUsed > 0)
            {
                if (GetCharCount(bytes, byteIndex, bytesUsed, flush) <= charCount)
                {
                    charsUsed = GetChars(bytes, byteIndex, bytesUsed, chars, charIndex, flush);
                    completed = (bytesUsed == byteCount &&
                        (m_fallbackBuffer == null || m_fallbackBuffer.Remaining == 0));
                    return;
                }

                // Try again with 1/2 the count, won't flush then 'cause won't read it all
                flush = false;
                bytesUsed /= 2;
            }

            // Oops, we didn't have anything, we'll have to throw an overflow
            throw new ArgumentException(Environment.GetResourceString("Argument_ConversionOverflow"));
        }

Same methods

Decoder::Convert ( byte bytes, int byteCount, char chars, int charCount, bool flush, int &bytesUsed, int &charsUsed, bool &completed ) : void

Usage Example

Exemple #1
0
        public static void Convert(this System.Text.Decoder decoder, Collections.Buffer <byte> bytes, Collections.Buffer <char> charBuffer)
        {
            int  bytesUsed;
            int  charsUsed;
            bool completed;

            decoder.Convert(bytes, charBuffer, out bytesUsed, out charsUsed, out completed);
        }
All Usage Examples Of System.Text.Decoder::Convert