public void Append <T>(T value, bool littleEndian = false) { Type t = typeof(T); if (!IsValidType(t)) { throw new Exception("msg_t.AppendMessage: Invalid type!"); } if (t == typeof(bool)) { xbc.WriteInt32(DataBuffer + MessageLength, ((bool)(object)value == true) ? 1 : 0); MessageLength += 4; } else if (t == typeof(string)) { xbc.WriteString xbc.WriteString(DataBuffer + MessageLength, (string)(object)value, false); MessageLength += (uint)Encoding.UTF8.GetBytes((string)(object)value).Length; } else if (t == typeof(byte[])) { byte[] bytes = (byte[])(object)value; xbc.SetMemory(DataBuffer + MessageLength, bytes); MessageLength += (uint)bytes.Length; } else if (t == typeof(byte)) { xbc.WriteByte(DataBuffer + MessageLength, (byte)(object)value); MessageLength += 1; } else { var bytes = typeof(BitConverter) .GetMethod("GetBytes", new Type[] { value.GetType() }) .Invoke(null, new object[] { value }); byte[] data = (byte[])(object)bytes; if (!littleEndian) { Array.Reverse(data); } xbc.SetMemory(DataBuffer + MessageLength, data); MessageLength += (uint)data.Length; } UpdateOverflowedBoolean(); }