示例#1
0
 static void push_primitive(object obj, FieldInfo field, BuffBuilder bb)
 {
     if (field.FieldType == typeof(uint))
     {
         bb.PushUint((uint)field.GetValue(obj));
     }
     else if (field.FieldType == typeof(int))
     {
         bb.PushInt((int)field.GetValue(obj));
     }
     else if (field.FieldType == typeof(ushort))
     {
         bb.PushUshort((ushort)field.GetValue(obj));
     }
     else if (field.FieldType == typeof(short))
     {
         bb.PushShort((short)field.GetValue(obj));
     }
     else if (field.FieldType == typeof(ulong))
     {
         bb.PushUlong((ulong)field.GetValue(obj));
     }
     else if (field.FieldType == typeof(long))
     {
         bb.PushLong((long)field.GetValue(obj));
     }
     else if (field.FieldType == typeof(byte))
     {
         bb.PushByte((byte)field.GetValue(obj));
     }
     else if (field.FieldType == typeof(float))
     {
         bb.PushFloat((float)field.GetValue(obj));
     }
 }
示例#2
0
 static void push_primitive_array(object obj, uint length, FieldInfo field, BuffBuilder bb)
 {
     System.Type elemtype = field.FieldType.GetElementType();
     if (elemtype == typeof(uint))
     {
         uint[] objs = (uint[])field.GetValue(obj);
         for (uint j = 0; j < length; ++j)
         {
             bb.PushUint(objs[j]);
         }
     }
     else if (elemtype == typeof(int))
     {
         int[] objs = (int[])field.GetValue(obj);
         for (uint j = 0; j < length; ++j)
         {
             bb.PushInt(objs[j]);
         }
     }
     else if (elemtype == typeof(ushort))
     {
         ushort[] objs = (ushort[])field.GetValue(obj);
         for (uint j = 0; j < length; ++j)
         {
             bb.PushUshort(objs[j]);
         }
     }
     else if (elemtype == typeof(short))
     {
         short[] objs = (short[])field.GetValue(obj);
         for (uint j = 0; j < length; ++j)
         {
             bb.PushShort(objs[j]);
         }
     }
     else if (elemtype == typeof(ulong))
     {
         ulong[] objs = (ulong[])field.GetValue(obj);
         for (uint j = 0; j < length; ++j)
         {
             bb.PushUlong(objs[j]);
         }
     }
     else if (elemtype == typeof(long))
     {
         long[] objs = (long[])field.GetValue(obj);
         for (uint j = 0; j < length; ++j)
         {
             bb.PushLong(objs[j]);
         }
     }
     else if (elemtype == typeof(byte))
     {
         byte[] objs = (byte[])field.GetValue(obj);
         for (uint j = 0; j < length; ++j)
         {
             bb.PushByte(objs[j]);
         }
     }
     else if (elemtype == typeof(float))
     {
         float[] objs = (float[])field.GetValue(obj);
         for (uint j = 0; j < length; ++j)
         {
             bb.PushFloat(objs[j]);
         }
     }
 }