mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-21 20:13:06 +00:00
Update framework reference so it's the older one
This commit is contained in:
parent
979b39d374
commit
81e48cd20e
1 changed files with 17 additions and 19 deletions
|
@ -83,21 +83,18 @@ namespace Toolbox.Library.IO
|
|||
if (!isBigEndian)
|
||||
return;
|
||||
|
||||
Console.WriteLine("type " + type + " " + type.IsPrimitive);
|
||||
|
||||
if (type.IsPrimitive)
|
||||
{
|
||||
if (type == typeof(short) || type == typeof(ushort) ||
|
||||
type == typeof(int) || type == typeof(uint) ||
|
||||
type == typeof(long) || type == typeof(ulong))
|
||||
type == typeof(long) || type == typeof(ulong) ||
|
||||
type == typeof(double) || type == typeof(float))
|
||||
{
|
||||
Array.Reverse(buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("GetFields " + type.GetFields().Length);
|
||||
|
||||
foreach (var field in type.GetFields())
|
||||
{
|
||||
var fieldType = field.FieldType;
|
||||
|
@ -108,26 +105,27 @@ namespace Toolbox.Library.IO
|
|||
if (fieldType.BaseType == typeof(Enum) && fieldType != typeof(ByteOrder))
|
||||
fieldType = fieldType.GetFields()[0].FieldType;
|
||||
|
||||
// Swap bytes only for the following types (incomplete just like BinaryReaderX is)
|
||||
var offset = Marshal.OffsetOf(type, field.Name).ToInt32();
|
||||
// Enums
|
||||
if (fieldType.IsEnum)
|
||||
fieldType = Enum.GetUnderlyingType(fieldType);
|
||||
|
||||
// Check for sub-fields to recurse if necessary
|
||||
var subFields = fieldType.GetFields().Where(subField => subField.IsStatic == false).ToArray();
|
||||
var effectiveOffset = startOffset + offset;
|
||||
|
||||
if (fieldType == typeof(short) || fieldType == typeof(ushort) ||
|
||||
fieldType == typeof(int) || fieldType == typeof(uint) ||
|
||||
fieldType == typeof(long) || fieldType == typeof(ulong))
|
||||
fieldType == typeof(long) || fieldType == typeof(ulong) ||
|
||||
fieldType == typeof(double) || fieldType == typeof(float))
|
||||
{
|
||||
var offset = Marshal.OffsetOf(type, field.Name).ToInt32();
|
||||
|
||||
// Enums
|
||||
if (fieldType.IsEnum)
|
||||
fieldType = Enum.GetUnderlyingType(fieldType);
|
||||
|
||||
// Check for sub-fields to recurse if necessary
|
||||
var subFields = fieldType.GetFields().Where(subField => subField.IsStatic == false).ToArray();
|
||||
var effectiveOffset = startOffset + offset;
|
||||
|
||||
if (subFields.Length == 0)
|
||||
Array.Reverse(buffer, effectiveOffset, Marshal.SizeOf(fieldType));
|
||||
else
|
||||
AdjustBigEndianByteOrder(fieldType, buffer, isBigEndian, effectiveOffset);
|
||||
|
||||
}
|
||||
|
||||
if (subFields.Length > 0)
|
||||
AdjustBigEndianByteOrder(fieldType, buffer, isBigEndian, effectiveOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue