using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace mdfinder
{
public class URIConverter : IValueConverter
{
/// Converts a value.
/// The value produced by the binding source.
/// The type of the binding target property.
/// The converter parameter to use.
/// The culture to use in the converter.
///
/// A converted value. If the method returns , the valid null value is
/// used.
///
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value != null)
{
var uri = value as Uri;
return uri.LocalPath;
}
else
{
return string.Empty;
}
}
/// Converts a value.
/// The value that is produced by the binding target.
/// The type to convert to.
/// The converter parameter to use.
/// The culture to use in the converter.
///
/// A converted value. If the method returns , the valid null value is
/// used.
///
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Uri uri = new Uri((string)value);
return uri;
}
}
}