Skip to content

Instantly share code, notes, and snippets.

@jzebedee
Created August 29, 2014 20:05
Show Gist options
  • Save jzebedee/b158cbbf5b86038ee5b9 to your computer and use it in GitHub Desktop.
Save jzebedee/b158cbbf5b86038ee5b9 to your computer and use it in GitHub Desktop.
boxing
Value = field.GetValue(this);
IOType = valueType = field.FieldType;
if (Value is Enum)
IOType = enumType = Enum.GetUnderlyingType(valueType);
else
enumType = null;
if (IOType == typeof(float))
writer.Write((float)(object)Value);
else if (IOType == typeof(uint))
writer.Write((uint)(object)Value);
else if (IOType == typeof(int))
writer.Write((int)(object)Value);
else if (IOType == typeof(ushort))
writer.Write((ushort)(object)Value);
else if (IOType == typeof(short))
writer.Write((short)(object)Value);
else if (IOType == typeof(byte))
writer.Write((byte)(object)Value);
else if (IOType == typeof(sbyte))
writer.Write((sbyte)(object)Value);
else if (IOType == typeof(bool))
if ((bool)(object)Value)
writer.Write((byte)1);
else
writer.Write((byte)0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment