Beispiel #1
0
        public static void Start()
        {
            Student oStudent = new Student();

            DynamicBuffer oByteArray = new DynamicBuffer();

            oByteArray.WriteByte(1);
            oByteArray.WriteUTF8("赵燕秋");
            oByteArray.WriteInt16(4);
            oByteArray.WriteUInt32(12);
            oByteArray.WriteUInt64(78);
            oByteArray.WriteFloat(15.6f);
            oByteArray.WriteDouble(90.123111);
            oByteArray.WriteInt32(2);
            oByteArray.WriteUTF8("你好世界!");
            byte[] bytes       = Encoding.UTF8.GetBytes("冬去春来!");
            byte[] lenghtBytes = BitConverter.GetBytes(bytes.Length);
            oByteArray.WriteBytes(lenghtBytes, 0, lenghtBytes.Length);
            oByteArray.WriteBytes(bytes, 0, bytes.Length);

            DynamicBuffer oTmpArray = new DynamicBuffer(oByteArray.Buffer);

            Console.WriteLine(oTmpArray.ReadByte());
            Console.WriteLine(oTmpArray.ReadUTF8());
            Console.WriteLine(oTmpArray.ReadInt16());
            Console.WriteLine(oTmpArray.ReadUInt32());
            Console.WriteLine(oTmpArray.ReadUInt64());
            Console.WriteLine(oTmpArray.ReadFloat());
            Console.WriteLine(oTmpArray.ReadDouble());
            Console.WriteLine(oTmpArray.ReadInt32());
            Console.WriteLine(oTmpArray.ReadUTF8());
            Console.WriteLine(oTmpArray.ReadUTF8());
            Console.ReadKey();
        }
Beispiel #2
0
 public void Setup(Type type, DynamicBuffer buffer)
 {
     Count = buffer.ReadInt32(); // 读取数据行数
     for (int i = 0; i < Count; i++)
     {
         BaseTpl oTpl = Activator.CreateInstance(type) as BaseTpl;
         if (oTpl != null)
         {
             oTpl.Deserialization(buffer);
         }
         TplDict.Add(oTpl.ID, oTpl);
     }
 }
Beispiel #3
0
 public override void Deserialization(DynamicBuffer oBuffer)
 {
     ID   = oBuffer.ReadInt32();
     Name = oBuffer.ReadUTF8();
 }
 public override void Deserialization(DynamicBuffer oBuffer)
 {
     UserID = oBuffer.ReadInt32();
 }