Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Windows.Data;
|
---|
6 | using System.Globalization;
|
---|
7 | using System.Diagnostics.Contracts;
|
---|
8 |
|
---|
9 | namespace Microsoft.Research.DynamicDataDisplay.Common.Auxiliary
|
---|
10 | {
|
---|
11 | public class GenericLambdaConverter<TIn, TOut> : IValueConverter
|
---|
12 | {
|
---|
13 | private readonly Func<TIn, TOut> lambda;
|
---|
14 |
|
---|
15 | /// <summary>
|
---|
16 | /// Initializes a new instance of the <see cref="GenericLambdaConverter<TIn, TOut>"/> class.
|
---|
17 | /// </summary>
|
---|
18 | /// <param name="lambda">The lambda.</param>
|
---|
19 | public GenericLambdaConverter(Func<TIn, TOut> lambda)
|
---|
20 | {
|
---|
21 | Contract.Assert(lambda != null);
|
---|
22 |
|
---|
23 | this.lambda = lambda;
|
---|
24 | }
|
---|
25 |
|
---|
26 | #region IValueConverter Members
|
---|
27 |
|
---|
28 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
---|
29 | {
|
---|
30 | TIn arg = (TIn)value;
|
---|
31 | TOut result = lambda(arg);
|
---|
32 | return result;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
---|
36 | {
|
---|
37 | throw new NotImplementedException();
|
---|
38 | }
|
---|
39 |
|
---|
40 | #endregion
|
---|
41 | }
|
---|
42 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.