using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; using System.Globalization; using System.Diagnostics.Contracts; namespace Microsoft.Research.DynamicDataDisplay.Common.Auxiliary { public class GenericLambdaConverter : IValueConverter { private readonly Func lambda; /// /// Initializes a new instance of the class. /// /// The lambda. public GenericLambdaConverter(Func lambda) { Contract.Assert(lambda != null); this.lambda = lambda; } #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { TIn arg = (TIn)value; TOut result = lambda(arg); return result; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } #endregion } }