Ejemplo n.º 1
0
 public static long ReadInt64(Stream stream)
 {
     using (var r = new BinReader(stream))
     {
         return r.ReadInt64();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Read an object in type_id/value format.
        /// </summary>
        /// <param name="inStream"></param>
        /// <returns></returns>
        public static Object getObject(Stream inStream)
        {
            using (BinReader r = new BinReader(inStream))
            {
                int type = r.ReadInt32();

                switch (type)
                {
                    case TYPE_INT32:
                        return r.ReadInt32();
                    case TYPE_INT64:
                        return r.ReadInt64();
                    case TYPE_REAL64:
                        return r.ReadDouble();
                    case TYPE_STRING:
                        return getString(inStream);
                    case TYPE_OPAQUE:
                        return getBytes(inStream);
                    default:
                        throw new ProtocolCodecException("Unknown type code: " + type);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Read a length-demlimited array of longs.
        /// </summary>
        /// <param name="inStream"></param>
        /// <returns></returns>
        public static long[] getLongArray(Stream inStream)
        {
            long[] longs = new long[getPositiveInt(inStream)];

            using (BinReader r = new BinReader(inStream))
            {
                for (int i = 0; i < longs.Length; i++)
                    longs[i] = r.ReadInt64();
            }

            return longs;
        }