using System; using System.Globalization; using System.Reflection; using System.Windows.Data; using JD.Guinness.WPF.Module.Model; namespace JD.Guinness.WPF.Module.Converter { public sealed class ChallengeToPlatformChallengeConverter : IValueConverter { private static readonly MethodInfo _getPlatformChallenge = typeof(Challenge).GetMethod(nameof(Challenge.GetPlatformChallenge)); public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value is Challenge challenge && parameter is Type type ? _getPlatformChallenge.MakeGenericMethod(type).Invoke(challenge, null) : null; public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException(); } }