mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +00:00
Applied some C#12 stuff
This commit is contained in:
1 parent
0444730aca
commit
d85f1559b3
105 files changed
+329
-422
No files matched your search
@@ -37,13 +37,13 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX86NativePaths { get; } = new() { "x86/CMSDK.dll" };
|
||||
public static List<string> PossibleX86NativePaths { get; } = ["x86/CMSDK.dll"];
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX64NativePaths { get; } = new() { "x64/CMSDK.dll" };
|
||||
public static List<string> PossibleX64NativePaths { get; } = ["x64/CMSDK.dll"];
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -5,5 +5,4 @@ namespace RGB.NET.Devices.CoolerMaster;
|
||||
/// <summary>
|
||||
/// Represents a CoolerMaster RGB-device.
|
||||
/// </summary>
|
||||
public interface ICoolerMasterRGBDevice : IRGBDevice
|
||||
{ }
|
||||
public interface ICoolerMasterRGBDevice : IRGBDevice;
|
||||
@@ -16,14 +16,14 @@ internal static class _CoolerMasterSDK
|
||||
{
|
||||
#region Libary Management
|
||||
|
||||
private static IntPtr _handle = IntPtr.Zero;
|
||||
private static nint _handle = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the SDK.
|
||||
/// </summary>
|
||||
internal static void Reload()
|
||||
{
|
||||
if (_handle != IntPtr.Zero)
|
||||
if (_handle != 0)
|
||||
{
|
||||
foreach (CoolerMasterDevicesIndexes index in Enum.GetValues(typeof(CoolerMasterDevicesIndexes)))
|
||||
EnableLedControl(false, index);
|
||||
@@ -34,7 +34,7 @@ internal static class _CoolerMasterSDK
|
||||
|
||||
private static void LoadCMSDK()
|
||||
{
|
||||
if (_handle != IntPtr.Zero) return;
|
||||
if (_handle != 0) return;
|
||||
|
||||
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
||||
List<string> possiblePathList = (Environment.Is64BitProcess ? CoolerMasterDeviceProvider.PossibleX64NativePaths : CoolerMasterDeviceProvider.PossibleX86NativePaths)
|
||||
@@ -47,7 +47,7 @@ internal static class _CoolerMasterSDK
|
||||
#if NET6_0
|
||||
if (_handle == IntPtr.Zero) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
|
||||
#else
|
||||
if (_handle == IntPtr.Zero) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
|
||||
if (_handle == 0) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
|
||||
#endif
|
||||
|
||||
_getSDKVersionPointer = (GetSDKVersionPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_handle, "GetCM_SDK_DllVer"), typeof(GetSDKVersionPointer));
|
||||
@@ -62,7 +62,7 @@ internal static class _CoolerMasterSDK
|
||||
|
||||
internal static void UnloadCMSDK()
|
||||
{
|
||||
if (_handle == IntPtr.Zero) return;
|
||||
if (_handle == 0) return;
|
||||
|
||||
_getSDKVersionPointer = null;
|
||||
_setControlDevicenPointer = null;
|
||||
@@ -74,14 +74,14 @@ internal static class _CoolerMasterSDK
|
||||
_setAllLedColorPointer = null;
|
||||
|
||||
NativeLibrary.Free(_handle);
|
||||
_handle = IntPtr.Zero;
|
||||
_handle = 0;
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr LoadLibrary(string dllToLoad);
|
||||
private static extern nint LoadLibrary(string dllToLoad);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Ansi)]
|
||||
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
|
||||
private static extern nint GetProcAddress(nint dllHandle, string name);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in new issue
Block a user