Exemple #1
0
    static void ShowOne(uint val)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            StreamPacker.PackUInt32(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(uint first, uint count)
    {
        using (Stream strm = new MemoryStream((int)(count * 4)))
        {
            uint i, j, k;

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

            strm.Position = 0;

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