mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +00:00
Added SteelSeries-Support
This commit is contained in:
1 parent
afbc25e1b2
commit
65a291500b
19 files changed
+1048
No files matched your search
@@ -0,0 +1,20 @@
|
||||
namespace RGB.NET.Devices.SteelSeries
|
||||
{
|
||||
internal class APIName : System.Attribute
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public APIName(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace RGB.NET.Devices.SteelSeries
|
||||
{
|
||||
internal static class SteelSeriesEnumExtension
|
||||
{
|
||||
#region Properties & Fields
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
private static readonly Dictionary<SteelSeriesDeviceType, string> _deviceTypeNames = new Dictionary<SteelSeriesDeviceType, string>();
|
||||
private static readonly Dictionary<SteelSeriesLedId, string> _ledIdNames = new Dictionary<SteelSeriesLedId, string>();
|
||||
|
||||
// ReSharper restore InconsistentNaming
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
internal static string GetAPIName(this SteelSeriesDeviceType deviceType)
|
||||
{
|
||||
if (!_deviceTypeNames.TryGetValue(deviceType, out string apiName))
|
||||
_deviceTypeNames.Add(deviceType, apiName = GetAPIName(typeof(SteelSeriesDeviceType), deviceType));
|
||||
|
||||
return apiName;
|
||||
}
|
||||
|
||||
internal static string GetAPIName(this SteelSeriesLedId ledId)
|
||||
{
|
||||
if (!_ledIdNames.TryGetValue(ledId, out string apiName))
|
||||
_ledIdNames.Add(ledId, apiName = GetAPIName(typeof(SteelSeriesLedId), ledId));
|
||||
|
||||
return apiName;
|
||||
}
|
||||
|
||||
private static string GetAPIName(Type type, Enum value)
|
||||
{
|
||||
MemberInfo[] memInfo = type.GetMember(value.ToString());
|
||||
if (memInfo.Length == 0) return null;
|
||||
return (memInfo.FirstOrDefault()?.GetCustomAttributes(typeof(APIName), false).FirstOrDefault() as APIName)?.Name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user