using System.Text.RegularExpressions; using RGB.NET.Core; using RGB.NET.Devices.Corsair.Native; namespace RGB.NET.Devices.Corsair; /// /// /// Represents a generic information for a Corsair-. /// public class CorsairRGBDeviceInfo : IRGBDeviceInfo { #region Properties & Fields /// /// Gets the corsair specific device type. /// public CorsairDeviceType CorsairDeviceType { get; } /// public RGBDeviceType DeviceType { get; } /// public string DeviceName { get; } /// public string Manufacturer => "Corsair"; /// public string Model { get; } /// /// Returns the unique ID provided by the Corsair-SDK. /// Returns string.Empty for Custom devices. /// public string DeviceId { get; } /// public object? LayoutMetadata { get; set; } /// /// Gets the amount of LEDs this device contains. /// public int LedCount { get; } /// /// Gets the offset used to access the LEDs of this device. /// internal int LedOffset { get; } #endregion #region Constructors /// /// Internal constructor of managed . /// /// The index of the . /// The type of the . /// The native -struct internal CorsairRGBDeviceInfo(RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) { this.DeviceType = deviceType; this.CorsairDeviceType = nativeInfo.type; this.Model = nativeInfo.model == null ? string.Empty : Regex.Replace(nativeInfo.model ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase); this.DeviceId = nativeInfo.id ?? string.Empty; this.LedCount = ledCount; this.LedOffset = ledOffset; DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); } /// /// Internal constructor of managed . /// /// The index of the . /// The type of the . /// The native -struct /// The name of the device-model (overwrites the one provided with the device info). internal CorsairRGBDeviceInfo(RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName) { this.DeviceType = deviceType; this.CorsairDeviceType = nativeInfo.type; this.Model = modelName; this.DeviceId = nativeInfo.id ?? string.Empty; this.LedCount = ledCount; this.LedOffset = ledOffset; DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); } #endregion }