Beispiel #1
0
 void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
 {
     byte[] array = val as byte[];
     if (array == null)
     {
         char[] array2 = val as char[];
         if (array2 != null)
         {
             array = packet.Encoding.GetBytes(array2);
         }
         else
         {
             string text = val.ToString();
             if (length == 0)
             {
                 length = text.Length;
             }
             else
             {
                 text = text.Substring(0, length);
             }
             array = packet.Encoding.GetBytes(text);
         }
     }
     if (length == 0)
     {
         length = array.Length;
     }
     if (array == null)
     {
         throw new MySqlException("Only byte arrays and strings can be serialized by MySqlBinary");
     }
     if (binary)
     {
         packet.WriteLength((long)length);
         packet.Write(array, 0, length);
         return;
     }
     packet.WriteStringNoNull("_binary ");
     packet.WriteByte(39);
     MySqlBinary.EscapeByteArray(array, length, packet);
     packet.WriteByte(39);
 }
Beispiel #2
0
        IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal)
        {
            MySqlBinary mySqlBinary;

            if (nullVal)
            {
                mySqlBinary = new MySqlBinary(this.type, true);
            }
            else
            {
                if (length == -1L)
                {
                    length = packet.ReadFieldLength();
                }
                byte[] array = new byte[length];
                packet.Read(array, 0, (int)length);
                mySqlBinary = new MySqlBinary(this.type, array);
            }
            return(mySqlBinary);
        }
        IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal)
        {
            MySqlBinary b;

            if (nullVal)
            {
                b = new MySqlBinary(type, true);
            }
            else
            {
                if (length == -1)
                {
                    length = (long)packet.ReadFieldLength();
                }

                byte[] newBuff = new byte[length];
                packet.Read(newBuff, 0, (int)length);
                b = new MySqlBinary(type, newBuff);
            }
            return(b);
        }
Beispiel #4
0
        IMySqlValue IMySqlValue.ReadValue(MySqlStream stream, long length, bool nullVal)
        {
            MySqlBinary b;

            if (nullVal)
            {
                b = new MySqlBinary(type, true);
            }
            else
            {
                if (length == -1)
                {
                    length = (long)stream.ReadFieldLength();
                }

                byte[] newBuff = new byte[length];
                stream.Read(newBuff, 0, (int)length);
                b = new MySqlBinary(type, newBuff);
            }
            b.IsGuid = this.IsGuid;
            return(b);
        }
        IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal)
        {
            MySqlBinary b;
            if (nullVal)
                b = new MySqlBinary(type, true);
            else
            {
                if (length == -1)
                    length = (long)packet.ReadFieldLength();

                byte[] newBuff = new byte[length];
                packet.Read(newBuff, 0, (int)length);
                b = new MySqlBinary(type, newBuff);
            }
            return b;
        }
Beispiel #6
0
		IMySqlValue IMySqlValue.ReadValue(MySqlStream stream, long length, bool nullVal)
		{
            MySqlBinary b;
            if (nullVal)
                b = new MySqlBinary(type, true);
            else
            {
                if (length == -1)
                    length = (long)stream.ReadFieldLength();

                byte[] newBuff = new byte[length];
                stream.Read(newBuff, 0, (int)length);
                b = new MySqlBinary(type, newBuff);
            }
            b.IsGuid = this.IsGuid;
            return b;
		}