diff --git a/HWInfoPlugin.cs b/HWInfoPlugin.cs index e1f5f46..9ccc071 100644 --- a/HWInfoPlugin.cs +++ b/HWInfoPlugin.cs @@ -77,15 +77,14 @@ public void Update() HWInfoRegistryUpdateResult result = _hwInfoRegistry.UpdateValues(_sensors); if (!result.IsSuccess) { + var ids = String.Join(", ", result.MissingSensors.Select(x => x.Id)); if (++_updateFailCount >= 10) { - var ids = String.Join(", ", result.MissingSensors.Select(x => x.Id)); Close(); throw new Exception($"HWInfo sensor value went missing from registry: {ids}"); } else { - var ids = String.Join(", ", result.MissingSensors.Select(x => x.Id)); _logger.Log($"HWInfo sensor value went missing from registry: {ids}"); } } diff --git a/HWInfoRegistry.cs b/HWInfoRegistry.cs index 1675e05..819ab20 100644 --- a/HWInfoRegistry.cs +++ b/HWInfoRegistry.cs @@ -89,14 +89,10 @@ internal HWInfoRegistryUpdateResult UpdateValues(HWInfoPluginSensor[] sensors) object valueRaw = _key.GetValue(VALUE_RAW_REGISTRY_NAME + sensor.Index); - if ( valueRaw is string str && !string.IsNullOrEmpty(str) && float.TryParse(str, NumberStyles.Float, _format, out float res)) - { + if (valueRaw is string str && !string.IsNullOrEmpty(str) && float.TryParse(str, NumberStyles.Float, _format, out float res)) sensor.Value = res; - } else - { missings.Add(sensor); - } } return missings.Any() ? @@ -140,7 +136,12 @@ private static string GetId(RegistryKey subKey, int index) { var sensor = subKey.GetValue(SENSOR_REGISTRY_NAME + index); var label = subKey.GetValue(LABEL_REGISTRY_NAME + index); - var unit = (((string)subKey.GetValue(VALUE_REGISTRY_NAME + index)).Trim().Split(' ').Skip(1).FirstOrDefault() ?? string.Empty).ToUpperInvariant(); + var unit = (subKey.GetValue(VALUE_REGISTRY_NAME + index) + .ToString() + .Trim() + .Split(' ') + .Skip(1) + .FirstOrDefault() ?? string.Empty).ToUpperInvariant(); return $"HWInfo/{sensor}/{label}/{unit}"; }