示例#1
0
        public void ByteArrayBuilderBase64()
        {
            Energy.Base.ByteArrayBuilder b = new Energy.Base.ByteArrayBuilder();
            string s1 = "TWljcm9zb2Z0IFdpbmRvd3M=";

            b.WriteBase64(s1);
            b.Rewind();
            string s2 = b.ReadString();

            Assert.AreEqual("Microsoft Windows", s2);
            b.Clear();
            string s3 = "Gęś";

            b.WriteString(s3);
            b.Rewind();
            string s4 = b.ReadBase64();
            string s5 = "R8SZxZs=";

            Assert.AreEqual(s5, s4);
        }
示例#2
0
        private static void Example2()
        {
            Energy.Base.ByteArrayBuilder b = new Energy.Base.ByteArrayBuilder();
            b.Append((byte)1);
            b.Append((byte)2);
            b.Append((int)1);
            b.Append((int)2);
            b.Append("Zurück");
            b.Encoding = System.Text.Encoding.Unicode;
            b.Append("Zurück");
            b.Append(Guid.NewGuid());
            b.Rewind();
            Console.WriteLine(Energy.Base.Hex.Print(b.ToArray()));
            b.Rewind();
            b.Skip(2 + 8);
            string s1 = b.ReadString(System.Text.Encoding.UTF8);
            string s2 = b.ReadString(System.Text.Encoding.Unicode);

            Console.WriteLine("{0} {1}", s1, s2);
            Guid guid = b.ReadGuid();

            Console.WriteLine(Energy.Base.Hex.Print(guid.ToByteArray()));
        }
示例#3
0
        public void ByteArrayBuilderSequence()
        {
            Energy.Base.ByteArrayBuilder b = new Energy.Base.ByteArrayBuilder();
            Assert.IsTrue(b.Empty);
            b.WriteByte(1);
            b.WriteByte(2);
            byte t;

            b.Rewind();
            t = b.ReadByte();
            Assert.AreEqual(1, t);
            b.Tail();
            b.WriteByte(3);
            b.Seek(1);
            t = b.ReadByte();
            Assert.AreEqual(2, t);
            t = b.ReadByte();
            Assert.AreEqual(3, t);
            Assert.IsTrue(b.End);
        }