Created
November 23, 2010 05:06
-
-
Save karno/711286 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Data; | |
namespace Azrael.Converters | |
{ | |
// Converter templates | |
public abstract class TwoWayConverter<Source, Target> : IValueConverter | |
where Source : class | |
where Target : class | |
{ | |
public abstract Target ToTarget(Source input, object parameter); | |
public abstract Source ToSource(Target input, object parameter); | |
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |
{ | |
return ToTarget(value as Source, parameter); | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |
{ | |
return ToSource(value as Target, parameter); | |
} | |
} | |
public abstract class OneWayConverter<Source, Target> : IValueConverter | |
where Source : class | |
where Target : class | |
{ | |
public abstract Target ToTarget(Source input, object parameter); | |
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |
{ | |
return ToTarget(value as Source, parameter); | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment