mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Extract all converters into separate folder
This commit is contained in:
30
Wox/Converters/ConvertorBase.cs
Normal file
30
Wox/Converters/ConvertorBase.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user