System.Text.EncodingNLS.ThrowBytesOverflow C# (CSharp) Method

ThrowBytesOverflow() private method

private ThrowBytesOverflow ( EncoderNLS encoder, bool nothingEncoded ) : void
encoder EncoderNLS
nothingEncoded bool
return void
        internal void ThrowBytesOverflow(EncoderNLS encoder, bool nothingEncoded)
        {
            if (encoder == null || encoder.m_throwOnOverflow || nothingEncoded)
            {
                if (encoder != null && encoder.InternalHasFallbackBuffer)
                    encoder.FallbackBuffer.Reset();
                // Special message to include fallback type in case fallback's GetMaxCharCount is broken
                // This happens if user has implemented an encoder fallback with a broken GetMaxCharCount
                ThrowBytesOverflow();
            }

            // If we didn't throw, we are in convert and have to remember our flushing
            encoder.ClearMustFlush();
        }

Same methods

EncodingNLS::ThrowBytesOverflow ( ) : void

Usage Example

示例#1
0
        internal unsafe void MovePrevious(bool bThrow)
        {
            if (fallbackBufferHelper.bFallingBack)
            {
                fallbackBuffer.MovePrevious();                      // don't use last fallback
            }
            else
            {
                Debug.Assert(_chars > _charStart || (bThrow && (_bytes == _byteStart)),
                             "[EncodingByteBuffer.MovePrevious]expected previous data or throw");
                if (_chars > _charStart)
                {
                    _chars--;                                        // don't use last char
                }
            }

            if (bThrow)
            {
                _enc.ThrowBytesOverflow(_encoder, _bytes == _byteStart);    // Throw? (and reset fallback if not converting)
            }
        }