1
0

feat: got stuck with bug of Community.Mvvm generating codes

This commit is contained in:
2025-11-18 14:50:17 +08:00
parent 02118f4c0a
commit a1b1fcbf7b
11 changed files with 184 additions and 31 deletions

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace BallanceTasEditor.Converters {
public class GenericConverter<TIn, TOut> : IValueConverter {
private readonly Func<TIn, TOut> converter;
public GenericConverter(Func<TIn, TOut> converter) { this.converter = converter; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
if (value is TIn t) {
return converter(t);
} else {
return Binding.DoNothing;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return Binding.DoNothing;
}
}
public static class ConverterWarehouse {
public static readonly GenericConverter<int, string> FpsConverter =
new GenericConverter<int, string>((v) => Utils.FpsConverter.ToDelta(v).ToString());
}
}