using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Txgy.EWS.Client.Common.Enums;

namespace Txgy.EWS.Client.Common.Converters
{
    /// <summary>
    /// 枚举值转Bool值
    /// </summary>
    [ValueConversion(typeof(SelectSort), typeof(Boolean))]
    public class EnumToCheckedConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (value.ToString() == parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (bool)value ? Enum.Parse(targetType, parameter.ToString(), true) : null;
        }
    }
}
