Update LibreHardwareMonitor
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 3m10s
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 3m10s
- Some nullability updates
This commit is contained in:
@@ -11,15 +11,14 @@ namespace HardwareMonitorStatusWindow.StatusWindow;
|
||||
|
||||
public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
||||
{
|
||||
private readonly DataErrorDictionary _dataErrorDictionary;
|
||||
private readonly DataErrorDictionary _dataErrorDictionary = new();
|
||||
|
||||
public SensorEntry()
|
||||
{
|
||||
_dataErrorDictionary = new DataErrorDictionary();
|
||||
_dataErrorDictionary.ErrorsChanged += DataErrorDictionaryErrorsChanged;
|
||||
}
|
||||
|
||||
public string Label
|
||||
public string? Label
|
||||
{
|
||||
get;
|
||||
set
|
||||
@@ -31,7 +30,7 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
public string HardwareId
|
||||
public string? HardwareId
|
||||
{
|
||||
get;
|
||||
set
|
||||
@@ -41,7 +40,7 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
public string SensorId
|
||||
public string? SensorId
|
||||
{
|
||||
get;
|
||||
set
|
||||
@@ -52,7 +51,7 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Hardware? Hardware => Data.ComputerHardware.FirstOrDefault(h => h.Identifier.ToString() == HardwareId);
|
||||
public Hardware? Hardware => Data.ComputerHardware?.FirstOrDefault(h => h.Identifier.ToString() == HardwareId);
|
||||
|
||||
[JsonIgnore]
|
||||
public Sensor? Sensor => Hardware?.Sensors.FirstOrDefault(s => s.Identifier.ToString() == SensorId);
|
||||
@@ -60,19 +59,22 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
||||
[JsonIgnore]
|
||||
public bool HasErrors => _dataErrorDictionary.Any();
|
||||
|
||||
public IEnumerable GetErrors(string propertyName)
|
||||
public IEnumerable GetErrors(string? propertyName)
|
||||
{
|
||||
return _dataErrorDictionary.GetErrors(propertyName);
|
||||
if (string.IsNullOrWhiteSpace(propertyName))
|
||||
throw new InvalidOperationException();
|
||||
|
||||
return _dataErrorDictionary.GetErrors(propertyName) ?? Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
|
||||
public event EventHandler<DataErrorsChangedEventArgs>? ErrorsChanged;
|
||||
|
||||
private void DataErrorDictionaryErrorsChanged(object sender, DataErrorsChangedEventArgs e)
|
||||
private void DataErrorDictionaryErrorsChanged(object? sender, DataErrorsChangedEventArgs e)
|
||||
{
|
||||
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(e.PropertyName));
|
||||
}
|
||||
|
||||
private bool ValidateLabel(string newValue)
|
||||
private bool ValidateLabel(string? newValue)
|
||||
{
|
||||
_dataErrorDictionary.ClearErrors(nameof(Label));
|
||||
|
||||
@@ -84,14 +86,14 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
||||
return false;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
|
||||
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
||||
field = value;
|
||||
|
||||
Reference in New Issue
Block a user