public IConverter <TSource, TDestination> Converter <TConverter>() where TConverter : IConverter <TSource, TDestination>, new() { var converter = new TConverter(); Converters .Register(converter); return(converter); }
/// <summary> /// /// </summary> /// <typeparam name="TConverter"></typeparam> /// <param name="type"></param> public static void AddOrUpdateConverter <TConvertValueType, TConverter>() where TConverter : ITelegramBotCallbackDataConverter, new() { var type = typeof(TConvertValueType); if (_converters.ContainsKey(type)) { _converters[type] = new TConverter(); return; } _converters.Add(type, new TConverter()); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return(TConverter.ChangeType(value, targetType)); }