Remainder of revert and address identifier differently (#1455)
* Remainder of revert and address identifier differently * Update Identifier.cs
This commit is contained in:
@@ -20,7 +20,7 @@ internal sealed class HighFlowNext : Hardware
|
||||
private readonly Sensor[] _voltages = new Sensor[2];
|
||||
private readonly Sensor[] _alarms = new Sensor[4];
|
||||
|
||||
public HighFlowNext(HidDevice dev, ISettings settings) : base("high flow NEXT", new Identifier("aquacomputer", "hfn", dev.GetSerialNumber().Replace(" ", "")), settings)
|
||||
public HighFlowNext(HidDevice dev, ISettings settings) : base("high flow NEXT", new Identifier(dev.DevicePath), settings)
|
||||
{
|
||||
if (dev.TryOpen(out _stream))
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ internal sealed class GridV3 : Hardware
|
||||
private readonly HidStream _stream;
|
||||
private readonly Sensor[] _voltages = new Sensor[FANS_COUNT];
|
||||
|
||||
public GridV3(HidDevice dev, ISettings settings) : base("NZXT GRID+ V3", new Identifier("nzxt", "gridv3", dev.GetSerialNumber().TrimStart('0')), settings)
|
||||
public GridV3(HidDevice dev, ISettings settings) : base("NZXT GRID+ V3", new Identifier(dev.DevicePath), settings)
|
||||
{
|
||||
if (dev.TryOpen(out _stream))
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ internal sealed class KrakenV2 : Hardware
|
||||
|
||||
private DateTime _lastUpdate = DateTime.MinValue;
|
||||
|
||||
public KrakenV2(HidDevice dev, ISettings settings) : base("Nzxt Kraken X", new Identifier("nzxt", "krakenx", dev.GetSerialNumber().TrimStart('0')), settings)
|
||||
public KrakenV2(HidDevice dev, ISettings settings) : base("Nzxt Kraken X", new Identifier(dev.DevicePath), settings)
|
||||
{
|
||||
_device = dev;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ internal sealed class KrakenV3 : Hardware
|
||||
private volatile bool _controllingFans;
|
||||
private volatile bool _controllingPump;
|
||||
|
||||
public KrakenV3(HidDevice dev, ISettings settings) : base("Nzxt Kraken Z", new Identifier("nzxt", "krakenz", dev.GetSerialNumber().TrimStart('0')), settings)
|
||||
public KrakenV3(HidDevice dev, ISettings settings) : base("Nzxt Kraken Z", new Identifier(dev.DevicePath), settings)
|
||||
{
|
||||
switch (dev.ProductID)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// All Rights Reserved.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace LibreHardwareMonitor.Hardware;
|
||||
@@ -20,7 +19,7 @@ public class Identifier : IComparable<Identifier>
|
||||
|
||||
public Identifier(params string[] identifiers)
|
||||
{
|
||||
CheckIdentifiers(identifiers);
|
||||
CoerceIdentifiers(identifiers);
|
||||
StringBuilder s = new();
|
||||
for (int i = 0; i < identifiers.Length; i++)
|
||||
{
|
||||
@@ -38,7 +37,7 @@ public class Identifier : IComparable<Identifier>
|
||||
/// <param name="extensions">Additional parts by which the base <see cref="Identifier" /> will be extended.</param>
|
||||
public Identifier(Identifier identifier, params string[] extensions)
|
||||
{
|
||||
CheckIdentifiers(extensions);
|
||||
CoerceIdentifiers(extensions);
|
||||
StringBuilder s = new();
|
||||
s.Append(identifier);
|
||||
for (int i = 0; i < extensions.Length; i++)
|
||||
@@ -61,12 +60,13 @@ public class Identifier : IComparable<Identifier>
|
||||
StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private static void CheckIdentifiers(IEnumerable<string> identifiers)
|
||||
private static void CoerceIdentifiers(string[] identifiers)
|
||||
{
|
||||
foreach (string s in identifiers)
|
||||
for (int i = 0; i < identifiers.Length; i++)
|
||||
{
|
||||
if (s.Contains(" ") || s.Contains(Separator.ToString()))
|
||||
throw new ArgumentException("Invalid identifier");
|
||||
string s = identifiers[i];
|
||||
if (s.IndexOf(' ') >= 0)
|
||||
identifiers[i] = s.Replace(' ', '-');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user