static void push_primitive(object obj, Type valuetype, BuffBuilder bb) { if (valuetype == typeof(uint)) { bb.PushUint((uint)(obj)); } else if (valuetype == typeof(int)) { bb.PushInt((int)(obj)); } else if (valuetype == typeof(ushort)) { bb.PushUshort((ushort)(obj)); } else if (valuetype == typeof(short)) { bb.PushShort((short)(obj)); } else if (valuetype == typeof(ulong)) { bb.PushUlong((ulong)(obj)); } else if (valuetype == typeof(long)) { bb.PushLong((long)(obj)); } else if (valuetype == typeof(byte)) { bb.PushByte((byte)(obj)); } else if (valuetype == typeof(float)) { bb.PushFloat((float)(obj)); } else if (valuetype == typeof(bool)) { bb.PushBool((bool)(obj)); } }
static void push_primitive_array(object obj, int length, FieldInfo field, BuffBuilder bb) { System.Type elemtype = field.FieldType.GetElementType(); if (elemtype == typeof(uint)) { uint[] objs = (uint[])field.GetValue(obj); for (int 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 (int j = 0; j < length; ++j) { bb.PushUshort(objs[j]); } } else if (elemtype == typeof(short)) { short[] objs = (short[])field.GetValue(obj); for (int j = 0; j < length; ++j) { bb.PushShort(objs[j]); } } else if (elemtype == typeof(ulong)) { ulong[] objs = (ulong[])field.GetValue(obj); for (int j = 0; j < length; ++j) { bb.PushUlong(objs[j]); } } else if (elemtype == typeof(long)) { long[] objs = (long[])field.GetValue(obj); for (int j = 0; j < length; ++j) { bb.PushLong(objs[j]); } } else if (elemtype == typeof(byte)) { byte[] objs = (byte[])field.GetValue(obj); for (int j = 0; j < length; ++j) { bb.PushByte(objs[j]); } } else if (elemtype == typeof(float)) { float[] objs = (float[])field.GetValue(obj); for (int j = 0; j < length; ++j) { bb.PushFloat(objs[j]); } } else if (elemtype == typeof(bool)) { bool[] objs = (bool[])field.GetValue(obj); for (int j = 0; j < length; j++) { bb.PushBool(objs[j]); } } }