コード例 #1
0
ファイル: Tmp.cs プロジェクト: As-You-Like/DotNetStuff
        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));
 }