Files
6098/Cowain.Bake.BLL/Converter/VarValueConverter.cs

78 lines
2.6 KiB
C#

using Cowain.Bake.Common.Models;
using Cowain.Bake.Model.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Cowain.Bake.BLL.Converter
{
public class VarValueConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0] == null)
{
throw new ArgumentNullException("value[0] can not be null");
}
if (values[1] == null)
{
return null;
}
string varType = values[0].ToString();
string res = string.Empty;
if (values[1] is byte[] val && !string.IsNullOrEmpty(varType))
{
Variable variable = new Variable();
variable.VarType = varType;
//variable.CurValue = val;
Stopwatch sw = new Stopwatch();
sw.Start();
//switch (variable.VarType)
//{
// case "BOOL":
// res = variable.GetBool().ToString();
// break;
// case "BYTE":
// res = variable.GetByte().ToString();
// break;
// case "UINT16":
// res = variable.GetUInt16().ToString();
// break;
// case "INT16":
// res = variable.GetInt16().ToString();
// break;
// case "INT32":
// res = variable.GetInt32().ToString();
// break;
// case "UINT32":
// res = variable.GetUInt32().ToString();
// break;
// case "FLOAT":
// res = variable.GetFloat().ToString();
// break;
// default:
// break;
//}
int rt = (int)sw.ElapsedMilliseconds;
if (rt > 100)
{
//NLog.LogManager.GetCurrentClassLogger().Error("转换时间超时:" + rt);
}
}
return res;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}