Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mysteryx93 committed Jan 1, 2022
1 parent b36c619 commit ca4fa4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Avalonia/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace HanumanInstitute.MediaPlayer.Avalonia;
/// </summary>
public class TimeSpanToDoubleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
var valueAdd = System.Convert.ToDouble(parameter, CultureInfo.InvariantCulture);
return ((TimeSpan)value).TotalSeconds + valueAdd;
return ((TimeSpan?) value)?.TotalSeconds + valueAdd ?? 0.0;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
var valueAdd = System.Convert.ToDouble(parameter, CultureInfo.InvariantCulture);
return TimeSpan.FromSeconds((double)value - valueAdd);
return value != null ? TimeSpan.FromSeconds((double)value - valueAdd) : TimeSpan.Zero;
}
}
}
12 changes: 2 additions & 10 deletions Avalonia/Helpers/Mvvm/RelayCommandGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,7 @@ public RelayCommand(Action<T> execute, Predicate<T>? canExecute)
Justification = "This cannot be an event")]
public void RaiseCanExecuteChanged()
{
#if SILVERLIGHT
var handler = CanExecuteChanged;
if (handler != null)
{
handler(this, EventArgs.Empty);
}
#else
// CommandManager.InvalidateRequerySuggested();
#endif
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}

/// <summary>
Expand All @@ -120,7 +112,7 @@ public void RaiseCanExecuteChanged()
/// <returns>true if this command can be executed; otherwise, false.</returns>
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute((T)parameter);
return _canExecute?.Invoke((T)parameter) ?? true;
}

/// <summary>
Expand Down

0 comments on commit ca4fa4b

Please sign in to comment.