Refactor StructureToByteArrayBigEndian to use ISwapEndian interface

This commit is contained in:
2025-10-21 12:09:12 +01:00
parent d7f746c4eb
commit 309adcbe03

View File

@@ -399,8 +399,8 @@ public static class Marshal
/// <typeparam name="T">Type of the structure to marshal</typeparam>
/// <returns>The byte array representing the given structure</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static byte[] StructureToByteArrayBigEndian<T>(T str) where T : struct =>
StructureToByteArrayLittleEndian((T)SwapStructureMembersEndian(str));
public static byte[] StructureToByteArrayBigEndian<T>(T str) where T : struct, ISwapEndian<T> =>
StructureToByteArrayLittleEndian(str.SwapEndian());
/// <summary>Converts a hexadecimal string into a byte array</summary>
/// <param name="hex">Hexadecimal string</param>