Ejemplo n.º 1
0
        private unsafe void deSerialize(AutoCSer.BinaryDeSerializer deSerializer)
        {
            byte *read = deSerializer.Read;
            int   size = *(int *)read;

            if (size <= 0)
            {
                if (size == 0)
                {
                    Buffer.SetNull();
                    State              = (MemberState)(byte)*(int *)(read + sizeof(int));
                    deSerializer.Read += sizeof(int) * 2;
                }
                else
                {
                    Buffer.Start       = -size;
                    deSerializer.Read += sizeof(int);
                }
            }
            else if (size == Buffer.Length)
            {
                if (deSerializer.MoveReadAny(sizeof(int) + size + (-size & 3)))
                {
                    fixed(byte *bufferFixed = Buffer.GetFixedBuffer()) AutoCSer.Memory.Common.CopyNotNull(read + sizeof(int), bufferFixed + Buffer.Start, size);

                    State = MemberState.Remote;
                }
            }
            else
            {
                deSerializer.State = BinarySerialize.DeSerializeState.IndexOutOfRange;
            }
        }
Ejemplo n.º 2
0
 private unsafe void deSerialize(AutoCSer.BinaryDeSerializer deSerializer)
 {
     if (deSerializer.MoveReadAny(sizeof(ulong) * 4))
     {
         byte *dataStart = deSerializer.Read;
         Ticks    = *(ulong *)(dataStart - sizeof(ulong) * 4);
         Identity = *(ulong *)(dataStart - sizeof(ulong) * 3);
         Low      = *(ulong *)(dataStart - sizeof(ulong) * 2);
         High     = *(ulong *)(dataStart - sizeof(ulong));
     }
 }
Ejemplo n.º 3
0
        private unsafe void deSerialize(AutoCSer.BinaryDeSerializer deSerializer)
        {
            byte *read = deSerializer.Read;
            int   size = *(int *)read;

            if (size > 0)
            {
                int offset = -(size + sizeof(ushort)) & 3;
                if (deSerializer.MoveReadAny(size + offset + (sizeof(int) + sizeof(ulong) + sizeof(ushort))))
                {
                    Index = *(ulong *)(read + sizeof(int));
                    deSerializer.DeSerializeTcpServer(ref Buffer, read += sizeof(int) + sizeof(ulong), size);
                    BlockIndex = *(ushort *)(read + size);
                }
            }
            else
            {
                deSerializer.State = BinarySerialize.DeSerializeState.IndexOutOfRange;
            }
        }
Ejemplo n.º 4
0
        private static unsafe void deSerialize(AutoCSer.BinaryDeSerializer deSerializer, ref CustomClass value)
        {
            byte *read = deSerializer.CustomRead;

            if (deSerializer.MoveReadAny(sizeof(int)))
            {
                switch (*(int *)read)
                {
                case 1: value = new CustomClass {
                        Value = null
                }; return;

                case 2: value = new CustomClass {
                        Value = string.Empty
                }; return;

                default: deSerializer.MoveRead(-1); return;
                }
            }
        }