1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2026-03-23 23:38:45 +00:00

Merge pull request #444 from DarthAffe/NET10Fix

Fixed issue with changed API in .NET 10
This commit is contained in:
DarthAffe 2026-03-10 20:39:51 +01:00 committed by GitHub
commit d91e643de6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,5 @@
using System; using System;
using System.Linq; using System.Buffers.Binary;
namespace RGB.NET.Devices.DMX.E131; namespace RGB.NET.Devices.DMX.E131;
@ -12,13 +12,11 @@ internal static class E131DataPacketExtension
internal static void SetSequenceNumber(this byte[] data, byte sequenceNumber) => data[111] = sequenceNumber; internal static void SetSequenceNumber(this byte[] data, byte sequenceNumber) => data[111] = sequenceNumber;
internal static void SetUniverse(this byte[] data, short universe) => Array.Copy(ToBigEndian(BitConverter.GetBytes(universe)), 0, data, 113, 2); internal static void SetUniverse(this byte[] data, short universe) => BinaryPrimitives.TryWriteInt16BigEndian(data.AsSpan().Slice(113, 2), universe);
internal static void ClearColors(this byte[] data) => Array.Clear(data, 126, 512); internal static void ClearColors(this byte[] data) => Array.Clear(data, 126, 512);
internal static void SetChannel(this byte[] data, int channel, byte value) => data[126 + channel] = value; internal static void SetChannel(this byte[] data, int channel, byte value) => data[126 + channel] = value;
private static byte[] ToBigEndian(byte[] data) => BitConverter.IsLittleEndian ? data.Reverse().ToArray() : data;
#endregion #endregion
} }