using System; using System.Globalization; using System.Windows.Data; using System35; using JetBrains.Annotations; namespace JetBrains.UI.Avalon { /// /// The universal Avalon Value Converter. /// public class ValueConverter : IValueConverter { #region Data [NotNull] private readonly Func _converter; #endregion #region Init public ValueConverter([NotNull] Func converter) { if(converter == null) throw new ArgumentNullException("converter"); _converter = converter; } #endregion #region IValueConverter Members /// ///Converts a value. The data binding engine calls this method when it propagates a value from the binding source to the binding target. /// /// /// ///A converted value.If the method returns null, the valid null value is used.A return value of . indicates that the converter produced no value and that the binding uses the , if available, or the default value instead.A return value of . indicates that the binding does not transfer the value or use the or default value. /// /// ///The culture to use in the converter. ///The type of the binding target property. ///The converter parameter to use. ///The value produced by the binding source. public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return _converter((TSource)value); } /// ///Converts a value. The data binding engine calls this method when it propagates a value from the binding target to the binding source. /// /// /// ///A converted value.If the method returns null, the valid null value is used.A return value of . indicates that the converter produced no value and that to the binding uses the , if available, or the default value instead.A return value of . indicates that the binding does not transfer the value or use the or default value. /// /// ///The culture to use in the converter. ///The type to convert to. ///The converter parameter to use. ///The value that is produced by the binding target. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } #endregion } }