Example #1
0
 public static List <byte> NumberLiteralToTypeBuffer(string sNum, DbTypeID typeID, List <byte> buffer)
 {
     if (DbTypeID.INT == typeID)
     {
         Int32 x = Int32.Parse(sNum);
         if (null == buffer)
         {
             buffer = new List <byte>(1 + 4);
         }
         buffer.Clear();
         buffer.Add(0);
         Entry.ToBytesAppend((Int32)Entry.ToUInt32(x), buffer);
     }
     else if (DbTypeID.LONG == typeID)
     {
         Int64 x = Int64.Parse(sNum);
         if (null == buffer)
         {
             buffer = new List <byte>(1 + 8);
         }
         buffer.Clear();
         buffer.Add(0);
         Entry.ToBytesAppend64((Int64)Entry.ToUInt64(x), buffer);
     }
     else if (DbTypeID.DOUBLE == typeID)
     {
         double x = double.Parse(sNum);
         if (null == buffer)
         {
             buffer = new List <byte>(1 + 9);
         }
         buffer.Clear();
         buffer.Add(0);
         recordset rs = recordset.Prepare();
         rs.PutDouble(x);
         for (int id = 0; id < 9; id++)
         {
             buffer.Add(0);
         }
         rs.GetBytes(buffer, 1, 9);
     }
     else
     {
         // This type isn't comparable with a number!
         if (null == buffer)
         {
             buffer = new List <byte>(1);
         }
         buffer.Clear();
         buffer.Add(1); // Nullable byte; IsNull=true;
     }
     return(buffer);
 }
Example #2
0
            // _ReadNextLiteral kept for _ReadNextLiteral
            static List <byte> _NumberLiteralToType(string sNum, DbColumn ci)
            {
                List <byte> buf;

                if ("int" == ci.Type.Name)
                {
                    Int32 x = Int32.Parse(sNum);
                    buf = new List <byte>(1 + 4);
                    buf.Add(0);
                    Entry.ToBytesAppend((Int32)Entry.ToUInt32(x), buf);
                }
                else if ("long" == ci.Type.Name)
                {
                    Int64 x = Int64.Parse(sNum);
                    buf = new List <byte>(1 + 8);
                    buf.Add(0);
                    Entry.ToBytesAppend64((Int64)Entry.ToUInt64(x), buf);
                }
                else if ("double" == ci.Type.Name)
                {
                    double x = double.Parse(sNum);
                    buf = new List <byte>(1 + 9);
                    buf.Add(0);
                    recordset rs = recordset.Prepare();
                    rs.PutDouble(x);
                    for (int id = 0; id < 9; id++)
                    {
                        buf.Add(0);
                    }
                    rs.GetBytes(buf, 1, 9);
                }
                else
                {
                    // This type isn't comparable with a number!
                    buf = new List <byte>(1);
                    buf.Add(1); // Nullable byte; IsNull=true;
                }
                return(buf);
            }
Example #3
0
 public void PutDouble(double x)
 {
     rs.PutByte(0); //front byte
     rs.PutDouble(x);
 }