using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.Model.Monitor { /// /// 比较映射转换参数 /// public class CompareMappingConvert : JsonModel, IMappingConvert { /// /// /// public List Mappings { get; set; } /// /// 转换 /// public double Convert(double value, out bool succeed) { succeed = false; if (Mappings == null || Mappings.Count < 1) return value; var item = Mappings.Find(x => x.Meet(value)); if (item == null) return value; succeed = true; return item.Value; } /// /// 是否满足条件 /// public bool Meet(double value) { if (Mappings == null || Mappings.Count < 1) return default; return Mappings.Exists(x => x.Meet(value)); } } }