mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-27 05:04:11 -04:00
Fix nullability mismatch in WPF converters
This commit is contained in:
parent
057beaacd6
commit
4e69ff317b
6 changed files with 43 additions and 21 deletions
|
@ -10,7 +10,12 @@ public class ChannelToGroupKeyConverter : IValueConverter
|
|||
{
|
||||
public static ChannelToGroupKeyConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) =>
|
||||
value switch
|
||||
{
|
||||
Channel { IsThread: true, Parent: not null } channel
|
||||
|
@ -22,9 +27,9 @@ public class ChannelToGroupKeyConverter : IValueConverter
|
|||
};
|
||||
|
||||
public object ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => throw new NotSupportedException();
|
||||
}
|
||||
|
|
|
@ -9,15 +9,20 @@ public class DateTimeOffsetToDateTimeConverter : IValueConverter
|
|||
{
|
||||
public static DateTimeOffsetToDateTimeConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) =>
|
||||
value is DateTimeOffset dateTimeOffsetValue
|
||||
? dateTimeOffsetValue.DateTime
|
||||
: default(DateTime?);
|
||||
|
||||
public object? ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) =>
|
||||
value is DateTime dateTimeValue
|
||||
|
|
|
@ -10,13 +10,17 @@ public class ExportFormatToStringConverter : IValueConverter
|
|||
{
|
||||
public static ExportFormatToStringConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
value is ExportFormat exportFormatValue ? exportFormatValue.GetDisplayName() : default;
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is ExportFormat exportFormatValue ? exportFormatValue.GetDisplayName() : default;
|
||||
|
||||
public object ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => throw new NotSupportedException();
|
||||
}
|
||||
|
|
|
@ -9,13 +9,13 @@ public class InverseBoolConverter : IValueConverter
|
|||
{
|
||||
public static InverseBoolConverter Instance { get; } = new();
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
value is false;
|
||||
|
||||
public object ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is false;
|
||||
}
|
||||
|
|
|
@ -10,13 +10,17 @@ public class SnowflakeToDateTimeOffsetConverter : IValueConverter
|
|||
{
|
||||
public static SnowflakeToDateTimeOffsetConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
value is Snowflake snowflake ? snowflake.ToDate() : null;
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is Snowflake snowflake ? snowflake.ToDate() : null;
|
||||
|
||||
public object ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => throw new NotSupportedException();
|
||||
}
|
||||
|
|
|
@ -9,13 +9,17 @@ public class TimeSpanToDateTimeConverter : IValueConverter
|
|||
{
|
||||
public static TimeSpanToDateTimeConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
value is TimeSpan timeSpanValue ? DateTime.Today.Add(timeSpanValue) : default(DateTime?);
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is TimeSpan timeSpanValue ? DateTime.Today.Add(timeSpanValue) : default(DateTime?);
|
||||
|
||||
public object? ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is DateTime dateTimeValue ? dateTimeValue.TimeOfDay : default(TimeSpan?);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue