System.Data.SqlClient.TdsParser.TryReadPlpUnicodeCharsChunk C# (CSharp) Method

TryReadPlpUnicodeCharsChunk() private method

private TryReadPlpUnicodeCharsChunk ( char buff, int offst, int len, System.Data.SqlClient.TdsParserStateObject stateObj, int &charsRead ) : bool
buff char
offst int
len int
stateObj System.Data.SqlClient.TdsParserStateObject
charsRead int
return bool
        private bool TryReadPlpUnicodeCharsChunk(char[] buff, int offst, int len, TdsParserStateObject stateObj, out int charsRead)
        {
            Debug.Assert((buff == null && len == 0) || (buff.Length >= offst + len), "Invalid length sent to ReadPlpUnicodeChars()!");
            Debug.Assert((stateObj._longlen != 0) && (stateObj._longlen != TdsEnums.SQL_PLP_NULL),
                        "Out of sync plp read request");
            if (stateObj._longlenleft == 0)
            {
                Debug.Assert(false, "Out of sync read request");
                charsRead = 0;
                return true;
            }

            charsRead = len;

            // stateObj._longlenleft is in bytes
            if ((stateObj._longlenleft >> 1) < (ulong)len)
                charsRead = (int)(stateObj._longlenleft >> 1);

            for (int ii = 0; ii < charsRead; ii++)
            {
                if (!stateObj.TryReadChar(out buff[offst + ii]))
                {
                    return false;
                }
            }

            stateObj._longlenleft -= ((ulong)charsRead << 1);
            return true;
        }
TdsParser