Пример #1
0
        public static UInt32 SerializeCommand <T>(IInstanceSerializer <T> serializer, Byte commandID, T command, Buf buffer, UInt32 offset)
        {
            UInt32 commandLength = 1 + serializer.SerializationLength(command);

            offset = FrameProtocol.SetupFrame(buffer, offset, commandLength);
            buffer.array[offset++] = commandID;
            return(serializer.Serialize(buffer.array, offset, command));
        }
Пример #2
0
 public override UInt32 Serialize(Object instance, Byte[] array, UInt32 offset)
 {
     ElementType[] elements = CheckAndGetValue(instance);
     for (int i = 0; i < elements.Length; i++)
     {
         offset = elementSerializer.Serialize(array, offset, elements[i]);
     }
     return(offset);
 }
Пример #3
0
        public override UInt32 Serialize(Object instance, Byte[] array, UInt32 offset)
        {
            Object valueAsObject = fieldInfo.GetValue(instance);

            if (valueAsObject == null)
            {
                array.BigEndianSetUInt32Subtype(offset, 0, arraySizeByteCount);
                return(offset + arraySizeByteCount);
            }

            ElementType[] valueAsArray = (ElementType[])valueAsObject;

            array.BigEndianSetUInt32Subtype(offset, (UInt32)valueAsArray.Length, arraySizeByteCount);
            offset += arraySizeByteCount;

            for (int i = 0; i < valueAsArray.Length; i++)
            {
                offset = elementSerializer.Serialize(array, offset, valueAsArray[i]);
            }

            return(offset);
        }
Пример #4
0
 public UInt32 Serialize(byte[] bytes, UInt32 offset)
 {
     return(serializer.Serialize(bytes, offset, instance));
 }