Exemplo n.º 1
0
 /// <summary>
 /// Serialize the WrappedObject to the specified <see cref="FieldTrip.Buffer.ByteBuffer"/>.
 /// </summary>
 /// <param name="buf">The buffer to serialize to.</param>
 public void Serialize(ByteBuffer buf)
 {
     switch (Type) {
         case DataType.CHAR:
             buf.PutString(Array.ToString());
             break;
         case DataType.UINT8:
         case DataType.INT8:
             buf.Put((byte[])Array);
             break;
         case DataType.UINT16:
         case DataType.INT16:
             buf.AsShortBuffer().Put((short[])Array);
             break;
         case DataType.UINT32:
         case DataType.INT32:
             buf.AsIntBuffer().Put((int[])Array);
             break;
         case DataType.UINT64:
         case DataType.INT64:
             buf.AsLongBuffer().Put((long[])Array);
             break;
         case DataType.FLOAT32:
             buf.AsFloatBuffer().Put((float[])Array);
             break;
         case DataType.FLOAT64:
             buf.AsDoubleBuffer().Put((double[])Array);
             break;
     }
 }