Beispiel #1
0
        public new byte[] Serialize(object Entity, DynamicBuffer buffer, Dictionary <object, BufferPtr> referenceMaping)
        {
            if (Entity == null)
            {
                return(Сonstants.nullPtrBytres);
            }
            if (referenceMaping.ContainsKey(Entity))
            {
                var bufferPtr = referenceMaping[Entity];
                return(BitConverter.GetBytes(bufferPtr.position));
            }
            byte[] ptrBytes = base.Serialize(Entity, buffer, referenceMaping);
            short  ptr      = BitConverter.ToInt16(ptrBytes, 0);
            int    lenght   = BitConverter.ToInt32(buffer.CurrentBuffer, ptr);

            referenceMaping.Add(Entity, buffer.GetPtr(ptr, lenght));
            return(ptrBytes);
        }