예제 #1
0
 static object pop_primitive(Type FieldType, BuffParser bp)
 {
     if (FieldType == typeof(uint))
     {
         return(bp.PopUint());
     }
     else if (FieldType == typeof(int))
     {
         return(bp.PopInt());
     }
     else if (FieldType == typeof(ushort))
     {
         return(bp.PopUshort());
     }
     else if (FieldType == typeof(short))
     {
         return(bp.PopShort());
     }
     else if (FieldType == typeof(ulong))
     {
         return(bp.PopUint64());
     }
     else if (FieldType == typeof(long))
     {
         return(bp.PopLong());
     }
     else if (FieldType == typeof(byte))
     {
         return(bp.PopByte());
     }
     else if (FieldType == typeof(float))
     {
         return(bp.PopFloat());
     }
     else if (FieldType == typeof(bool))
     {
         return(bp.PopBool());
     }
     return(null);
 }
예제 #2
0
 static Array pop_primitive_array(int length, Type elemtype, BuffParser bp)
 {
     if (elemtype == typeof(uint))
     {
         uint[] objs = (uint[])Array.CreateInstance(elemtype, length);
         for (uint j = 0; j < length; ++j)
         {
             objs[j] = bp.PopUint32();
         }
         return(objs);
     }
     else if (elemtype == typeof(int))
     {
         int[] objs = (int[])Array.CreateInstance(elemtype, length);
         for (uint j = 0; j < length; ++j)
         {
             objs[j] = bp.PopInt32();
         }
         return(objs);
     }
     else if (elemtype == typeof(ushort))
     {
         ushort[] objs = (ushort[])Array.CreateInstance(elemtype, length);
         for (uint j = 0; j < length; ++j)
         {
             objs[j] = bp.PopUshort();
         }
         return(objs);
     }
     else if (elemtype == typeof(short))
     {
         short[] objs = (short[])Array.CreateInstance(elemtype, length);
         for (uint j = 0; j < length; ++j)
         {
             objs[j] = bp.PopShort();
         }
         return(objs);
     }
     else if (elemtype == typeof(ulong))
     {
         ulong[] objs = (ulong[])Array.CreateInstance(elemtype, length);
         for (uint j = 0; j < length; ++j)
         {
             objs[j] = bp.PopUlong();
         }
         return(objs);
     }
     else if (elemtype == typeof(long))
     {
         long[] objs = (long[])Array.CreateInstance(elemtype, length);
         for (uint j = 0; j < length; ++j)
         {
             objs[j] = bp.PopLong();
         }
         return(objs);
     }
     else if (elemtype == typeof(float))
     {
         float[] objs = (float[])Array.CreateInstance(elemtype, length);
         for (uint j = 0; j < length; ++j)
         {
             objs[j] = bp.PopFloat();
         }
         return(objs);
     }
     else if (elemtype == typeof(byte))
     {
         byte[] objs = (byte[])Array.CreateInstance(elemtype, length);
         objs = bp.PopBytes((int)length);
         return(objs);
     }
     else if (elemtype == typeof(bool))
     {
         bool[] objs = (bool[])Array.CreateInstance(elemtype, length);
         for (uint j = 0; j < length; ++j)
         {
             objs[j] = bp.PopBool();
         }
         return(objs);
     }
     return(null);
 }