From e1df9a97540224b7fdaec804edef8183226b2438 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 1 Mar 2021 23:02:45 -0800 Subject: [PATCH] Use Shadow's description converter implementation --- MPF/EnumDescriptionConverter.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/MPF/EnumDescriptionConverter.cs b/MPF/EnumDescriptionConverter.cs index fd72783f..27b3bd08 100644 --- a/MPF/EnumDescriptionConverter.cs +++ b/MPF/EnumDescriptionConverter.cs @@ -1,7 +1,6 @@ using System; using System.Globalization; using System.Windows.Data; -using MPF.Data; using MPF.Utilities; namespace MPF @@ -13,15 +12,15 @@ namespace MPF { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - // Common - if (value is MediaType?) - return ((MediaType?)value).LongName(); - else if (value is KnownSystem?) - return ((KnownSystem?)value).LongName(); + var sourceType = value.GetType(); + sourceType = Nullable.GetUnderlyingType(sourceType) ?? sourceType; - // Default + var method = typeof(Converters).GetMethod("LongName", new[] { typeof(Nullable<>).MakeGenericType(sourceType) }); + + if (method != null) + return method.Invoke(null, new[] { value }); else - return ""; + return string.Empty; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)