Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Rem0o committed Sep 23, 2022
1 parent 19e4423 commit 2c029f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions HWInfoPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
Expand Down
13 changes: 7 additions & 6 deletions HWInfoRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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() ?
Expand Down Expand Up @@ -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}";
}
Expand Down

0 comments on commit 2c029f8

Please sign in to comment.