Exemple #1
0
    static void ShowOne(ulong val)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            StreamPacker.PackUInt64(ms, val);
            ms.Position = 0;
            byte[] bytes = ms.ToArray();
            Console.Write("{0,7}: ", val);
            foreach (byte b in bytes)
            {
                Console.Write("{0,2:X} ", b);
            }
//			Console.WriteLine ();
        }
    }
Exemple #2
0
    static void Check(ulong first, ulong count)
    {
        using (Stream strm = new MemoryStream((int)(count * 8)))
        {
            ulong i, j, k;

            for (i = 0, k = first; i < count; i++, k++)
            {
                StreamPacker.PackUInt64(strm, k);
            }

            strm.Position = 0;

            for (i = 0, k = first; i < count; i++, k++)
            {
                j = StreamPacker.UnpackInt64(strm);
                if (j != k)
                {
                    throw new Exception(string.Format("failed on {0}: {1}", k, j));
                }
            }
        }
    }