using System.Collections;
using System.Globalization;
using System.Windows.Data;

namespace BPA.SingleDevice.Converters
{
    public class DictionaryValueConverter: IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is IDictionary dictionary && parameter != null)
            {
                var key = parameter.ToString();
                if (dictionary.Contains(key))
                {
                    return dictionary[key];
                }
            }

            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}