using System;
using System.Windows.Data;
using System.Globalization;
using System.Windows.Media.Imaging;

namespace WPImageCaching
{
    public class ImageCacheConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is BitmapImage)
            {
                return ImageCache.GetImage((BitmapImage)value);    
            }
            else
            {
                return value;
            }
            
        }

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