Exemplo n.º 1
0
 /// <summary>
 ///  Reads the String from the current stream and advances the current position of the stream by String size.
 /// </summary>
 public static string ReadString(this BinaryReader reader, ColumnMeta meta)
 {
     if (meta != null && meta.Bits != 0x00)
     {
         throw new Exception("TypeCode.String Unknown meta.Bits");
     }
     return(reader.ReadStringNull());
 }
Exemplo n.º 2
0
 /// <summary>
 ///  Reads the Single from the current stream and advances the current position of the stream by Single size.
 /// </summary>
 public static float ReadSingle(this BinaryReader reader, ColumnMeta meta)
 {
     if (meta != null && meta.Bits != 0x00)
     {
         throw new Exception("TypeCode.Single Unknown meta.Bits");
     }
     return(reader.ReadSingle());
 }
Exemplo n.º 3
0
 /// <summary>
 ///  Reads the Double from the current stream and advances the current position of the stream by Double size.
 /// </summary>
 public static double ReadDouble(this BinaryReader reader, ColumnMeta meta)
 {
     if (meta != null && meta.Bits != -32)
     {
         throw new Exception("TypeCode.Double Unknown meta.Bits");
     }
     return(reader.ReadDouble());
 }
Exemplo n.º 4
0
        /// <summary>
        ///  Reads the UInt64 from the current stream and advances the current position of the stream by UInt64 size.
        /// </summary>
        public static ulong ReadUInt64(this BinaryReader reader, ColumnMeta meta)
        {
            if (meta == null)
            {
                return(reader.ReadUInt64());
            }
            else
            {
                byte[] b = reader.ReadBytes((32 - meta.Bits) >> 3);

                ulong u64 = 0;
                for (int i = 0; i < b.Length; i++)
                {
                    u64 |= ((ulong)b[i] << i * 8);
                }

                return(u64);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Reads the UInt32 from the current stream and advances the current position of the stream by UInt32 size.
        /// </summary>
        public static uint ReadUInt32(this BinaryReader reader, ColumnMeta meta)
        {
            if (meta == null)
            {
                return(reader.ReadUInt32());
            }
            else
            {
                byte[] b = reader.ReadBytes((32 - meta.Bits) >> 3);

                uint u32 = 0;
                for (int i = 0; i < b.Length; i++)
                {
                    u32 |= ((uint)b[i] << i * 8);
                }

                return(u32);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        ///  Reads the UInt16 from the current stream and advances the current position of the stream by UInt16 size.
        /// </summary>
        public static ushort ReadUInt16(this BinaryReader reader, ColumnMeta meta)
        {
            if (meta != null && meta.Bits != 0x10)
            {
                throw new Exception("TypeCode.UInt16 Unknown meta.Bits");
            }
            return(reader.ReadUInt16());
            //if (meta == null)
            //    return reader.ReadUInt16();
            //else
            //{
            //    byte[] b = reader.ReadBytes((32 - meta.Bits) >> 3);

            //    ushort u16 = 0;
            //    for (int i = 0; i < b.Length; i++)
            //        u16 |= (ushort)(b[i] << i * 8);

            //    return u16;
            //}
        }
Exemplo n.º 7
0
        /// <summary>
        ///  Reads the UInt8 from the current stream and advances the current position of the stream by UInt8 size.
        /// </summary>
        public static byte ReadUInt8(this BinaryReader reader, ColumnMeta meta)
        {
            if (meta != null && meta.Bits != 0x18)
            {
                throw new Exception("TypeCode.Byte Unknown meta.Bits");
            }
            return(reader.ReadByte());
            //if (meta == null)
            //    return reader.ReadByte();
            //else
            //{
            //    byte[] b = reader.ReadBytes((32 - meta.Bits) >> 3);

            //    byte u8 = 0;
            //    for (int i = 0; i < b.Length; i++)
            //        u8 |= (byte)(b[i] << i * 8);

            //    return u8;
            //}
        }
Exemplo n.º 8
0
 private void ReadStringField(int colIndex, ColumnMeta meta, DataRow dataRow, BinaryReader br)
 {
     if (m_dbreader is WDBReader)
     {
         dataRow.SetField(colIndex, br.ReadStringNull());
     }
     else if (m_dbreader is STLReader)
     {
         int offset = br.ReadInt32();
         dataRow.SetField(colIndex, (m_dbreader as STLReader).ReadString(offset));
     }
     else
     {
         try
         {
             dataRow.SetField(colIndex, m_dbreader.IsSparseTable ? br.ReadStringNull() : m_dbreader.StringTable[br.ReadInt32(meta)]);
         }
         catch
         {
             dataRow.SetField(colIndex, "Invalid string index!");
         }
     }
 }
Exemplo n.º 9
0
 private void ReadStringField(int colIndex, ColumnMeta meta, DataRow dataRow, BinaryReader br)
 {
     if (m_dbreader is WDBReader)
         dataRow.SetField(colIndex, br.ReadStringNull());
     else if (m_dbreader is STLReader)
     {
         int offset = br.ReadInt32();
         dataRow.SetField(colIndex, (m_dbreader as STLReader).ReadString(offset));
     }
     else
     {
         try
         {
             dataRow.SetField(colIndex, m_dbreader.IsSparseTable ? br.ReadStringNull() : m_dbreader.StringTable[br.ReadInt32(meta)]);
         }
         catch
         {
             dataRow.SetField(colIndex, "Invalid string index!");
         }
     }
 }