Extract all converters into separate folder

This commit is contained in:
Yaroslav Zyubanov
2014-05-24 14:06:09 +06:00
parent d748e34d7e
commit 9eefd8839c
6 changed files with 116 additions and 99 deletions

View File

@@ -0,0 +1,30 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;
namespace Wox.Converters
{
public abstract class ConvertorBase<T> : MarkupExtension, IValueConverter where T : class, new()
{
private static T converter;
/// <summary>
/// Must be implemented in inheritor.
/// </summary>
public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture);
/// <summary>
/// Override if needed.
/// </summary>
public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return converter ?? (converter = new T());
}
}
}