Exemple #1
0
        internal void WriteByteArray(Byte[] b, int len, int offsetBuffer, TdsParserStateObject stateObj)
        {
            int offset = offsetBuffer;

            while (len > 0)
            {
                if ((stateObj._outBytesUsed + len) > stateObj._outBuff.Length)
                {
                    int remainder = stateObj._outBuff.Length - stateObj._outBytesUsed;

                    Buffer.BlockCopy(b, offset, stateObj._outBuff, stateObj._outBytesUsed, remainder);

                    offset += remainder;
                    stateObj._outBytesUsed += remainder;

                    if (stateObj._outBytesUsed == stateObj._outBuff.Length)
                    {
                        stateObj.WritePacket(0);
                    }

                    len -= remainder;
                }
                else
                {
                    Buffer.BlockCopy(b, offset, stateObj._outBuff, stateObj._outBytesUsed, len);

                    stateObj._outBytesUsed += len;

                    break;
                }
            }
        }
Exemple #2
0
        internal void WriteByte(byte b, TdsParserStateObject stateObj)
        {
            if (stateObj._outBytesUsed == stateObj._outBuff.Length)
            {
                stateObj.WritePacket(0);
            }

            stateObj._outBuff[stateObj._outBytesUsed++] = b;
        }
Exemple #3
0
 internal void WriteShort(int v, TdsParserStateObject stateObj)
 {
     if ((stateObj._outBytesUsed + 2) > stateObj._outBuff.Length)
     {
         WriteByte((byte)(v & 0xff), stateObj);
         WriteByte((byte)((v >> 8) & 0xff), stateObj);
     }
     else
     {
         stateObj._outBuff[stateObj._outBytesUsed++] = (byte)(v & 0xFF);
         stateObj._outBuff[stateObj._outBytesUsed++] = (byte)((v >> 8) & 0xFF);
     }
 }
Exemple #4
0
        internal void WriteString(string s, int length, int offset, TdsParserStateObject stateObj)
        {
            int cBytes = 2 * length;

            if (cBytes < (stateObj._outBuff.Length - stateObj._outBytesUsed))
            {
                CopyStringToBytes(s, offset, stateObj._outBuff, stateObj._outBytesUsed, length);
                stateObj._outBytesUsed += cBytes;
            }
            else
            {
                if (stateObj._bTmp == null || stateObj._bTmp.Length < cBytes)
                {
                    stateObj._bTmp = new byte[cBytes];
                }

                CopyStringToBytes(s, offset, stateObj._bTmp, 0, length);
                WriteByteArray(stateObj._bTmp, cBytes, 0, stateObj);
            }
        }
Exemple #5
0
 private void WriteString(string s, TdsParserStateObject stateObj)
 {
     WriteString(s, s.Length, 0, stateObj);
 }
Exemple #6
0
 internal void WriteInt(int v, TdsParserStateObject stateObj)
 {
     WriteByteArray(BitConverter.GetBytes(v), 4, 0, stateObj);
 }
Exemple #7
0
 private void WriteString(string s, TdsParserStateObject stateObj)
 {
     WriteString(s, s.Length, 0, stateObj);
 }
Exemple #8
0
        internal void WriteString(string s, int length, int offset, TdsParserStateObject stateObj)
        {
            int cBytes = 2 * length;

            if (cBytes < (stateObj._outBuff.Length - stateObj._outBytesUsed))
            {
                CopyStringToBytes(s, offset, stateObj._outBuff, stateObj._outBytesUsed, length);
                stateObj._outBytesUsed += cBytes;
            }
            else
            {
                if (stateObj._bTmp == null || stateObj._bTmp.Length < cBytes)
                {
                    stateObj._bTmp = new byte[cBytes];
                }

                CopyStringToBytes(s, offset, stateObj._bTmp, 0, length);
                WriteByteArray(stateObj._bTmp, cBytes, 0, stateObj);
            }
        }
Exemple #9
0
 internal void WriteInt(int v, TdsParserStateObject stateObj)
 {
     WriteByteArray(BitConverter.GetBytes(v), 4, 0, stateObj);
 }
Exemple #10
0
 internal void WriteShort(int v, TdsParserStateObject stateObj)
 {
     if ((stateObj._outBytesUsed + 2) > stateObj._outBuff.Length)
     {
         WriteByte((byte)(v & 0xff), stateObj);
         WriteByte((byte)((v >> 8) & 0xff), stateObj);
     }
     else
     {
         stateObj._outBuff[stateObj._outBytesUsed++] = (byte)(v & 0xFF);
         stateObj._outBuff[stateObj._outBytesUsed++] = (byte)((v >> 8) & 0xFF);
     }
 }
Exemple #11
0
        internal void WriteByteArray(Byte[] b, int len, int offsetBuffer, TdsParserStateObject stateObj)
        {
            int offset = offsetBuffer;

            while (len > 0)
            {
                if ((stateObj._outBytesUsed + len) > stateObj._outBuff.Length)
                {
                    int remainder = stateObj._outBuff.Length - stateObj._outBytesUsed;

                    Buffer.BlockCopy(b, offset, stateObj._outBuff, stateObj._outBytesUsed, remainder);

                    offset += remainder;
                    stateObj._outBytesUsed += remainder;

                    if (stateObj._outBytesUsed == stateObj._outBuff.Length)
                    {
                        stateObj.WritePacket(0);
                    }

                    len -= remainder;
                }
                else
                {
                    Buffer.BlockCopy(b, offset, stateObj._outBuff, stateObj._outBytesUsed, len);

                    stateObj._outBytesUsed += len;

                    break;
                }
            }
        }
Exemple #12
0
        internal void WriteByte(byte b, TdsParserStateObject stateObj)
        {
            if (stateObj._outBytesUsed == stateObj._outBuff.Length)
            {
                stateObj.WritePacket(0);
            }

            stateObj._outBuff[stateObj._outBytesUsed++] = b;
        }