Ejemplo n.º 1
0
 public void Write(ByteBufferRef buf, int offset)
 {
     Contract.Assert(offset >= 0 && offset + Size <= buf.Length);
     Deserializer.WriteInt(fd, buf, offset);
     Deserializer.WriteShort(events, buf, offset + sizeof(int));
     Deserializer.WriteShort(revents, buf, offset + sizeof(int) + sizeof(short));
 }
Ejemplo n.º 2
0
        internal void WriteString16(string s)
        {
            var r = new ByteBufferRef(Buffer);

            if (cursor + sizeof(int) > Buffer.Length)
            {
                return;
            }

            WriteInt32(s.Length);

            foreach (var c in s)
            {
                if (cursor + sizeof(short) > r.Length)
                {
                    return;
                }
                Deserializer.WriteShort((short)c, r, cursor);
                cursor += sizeof(short);
            }

            if (cursor + sizeof(short) > r.Length)
            {
                return;
            }

            Deserializer.WriteShort(0, r, cursor);
            cursor += sizeof(short);
            Pad();
        }