Ejemplo n.º 1
0
        // Copy the data from the Stream to the array buffer.
        // If the SqlChars doesn't hold a buffer or the buffer
        // is not big enough, allocate new char array.
        private void CopyStreamToBuffer()
        {
            Debug.Assert(FStream());

            long lStreamLen = m_stream.Length;

            if (lStreamLen >= x_lMaxLen)
            {
                throw new SqlTypeException(Res.GetString(Res.SqlMisc_BufferInsufficientMessage));
            }

            if (m_rgchBuf == null || m_rgchBuf.Length < lStreamLen)
            {
                m_rgchBuf = new char[lStreamLen];
            }

            if (m_stream.Position != 0)
            {
                m_stream.Seek(0, SeekOrigin.Begin);
            }

            m_stream.Read(m_rgchBuf, 0, (int)lStreamLen);
            m_stream = null;
            _lCurLen = lStreamLen;
            _state   = SqlBytesCharsState.Buffer;

            AssertValid();
        }
Ejemplo n.º 2
0
        // --------------------------------------------------------------
        //	  Public methods
        // --------------------------------------------------------------

        public void SetNull()
        {
            _lCurLen = x_lNull;
            m_stream = null;
            _state   = SqlBytesCharsState.Null;

            AssertValid();
        }
Ejemplo n.º 3
0
        // Create a SqlChars from a SqlStreamChars
        internal SqlChars(SqlStreamChars s)
        {
            m_rgchBuf = null;
            _lCurLen  = x_lNull;
            m_stream  = s;
            _state    = (s == null) ? SqlBytesCharsState.Null : SqlBytesCharsState.Stream;

            _rgchWorkBuf = null;

            AssertValid();
        }
Ejemplo n.º 4
0
        // Create a SqlChars with an in-memory buffer
        public SqlChars(char[] buffer)
        {
            m_rgchBuf = buffer;
            m_stream  = null;
            if (m_rgchBuf == null)
            {
                _state   = SqlBytesCharsState.Null;
                _lCurLen = x_lNull;
            }
            else
            {
                _state   = SqlBytesCharsState.Buffer;
                _lCurLen = (long)m_rgchBuf.Length;
            }

            _rgchWorkBuf = null;

            AssertValid();
        }