using log4net; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using NoteManageAR; namespace UFIDA.U8.Framework.Api.ControlObject.Common { public class APARHelper { protected readonly ILog logInfo = LogManager.GetLogger("logInfo"); private readonly VoucherData _vd; private readonly PropertyInfo[] _props; public APARHelper(VoucherDataClass vd) { _vd = vd; var tp = vd.GetType(); _props = tp.GetProperties(); } public void SetValue(Dictionary dictionary) { foreach (var key in dictionary.Keys) { if (key != "body") logInfo.Debug($"正在设置字段:{key}--{dictionary[key]}"); if (!string.IsNullOrWhiteSpace($"{dictionary[key]}") && _props.Any(a => string.Equals(a.Name, key, StringComparison.OrdinalIgnoreCase))) { var prop = _props.First(a => string.Equals(a.Name, key, StringComparison.OrdinalIgnoreCase)); prop.SetPropValue(_vd, dictionary[key]); } } } } }