首次提交:添加src文件夹代码
This commit is contained in:
38
Cowain.Bake.Model/Converter/MachineTypeConverter.cs
Normal file
38
Cowain.Bake.Model/Converter/MachineTypeConverter.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Bake.DAL.Converter
|
||||
{
|
||||
public class MachineTypeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
if (value is int val)
|
||||
{
|
||||
var p = GlobalListData.MachineType.Where(x => x.Type == val).FirstOrDefault();
|
||||
if (null == p)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.Name;
|
||||
}
|
||||
|
||||
}
|
||||
throw new ArgumentNullException("value type is not int");
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user