首次提交:添加src文件夹代码
This commit is contained in:
45
Cowain.Bake.BLL/Converter/TaskTypeConverter.cs
Normal file
45
Cowain.Bake.BLL/Converter/TaskTypeConverter.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using Prism.Ioc;
|
||||
|
||||
namespace Cowain.Bake.BLL.Converter
|
||||
{
|
||||
public class TaskTypeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is int val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().TaskType.Where(x => x.Id == val).FirstOrDefault();
|
||||
if (null == p)
|
||||
{
|
||||
return "手动任务";
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.Name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().TaskType.Where(x => x.Name == val).FirstOrDefault();
|
||||
if (null == p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.Id;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user