/// <summary>
/// 保存时 对当前配置项进行赋值
/// </summary>
/// <param name="item">当前配置项</param>
/// <param name="ListOptions">配置项值</param>
public void SetValue(ConfigOption item, List <Options> ListOptions)
{
var desc = ConfigDescriptionCache.GetTypeDiscription(item.GetType());
Options option = null;
foreach (PropertyInfo prop in desc.StaticPropertyInfo)
{
option = ListOptions.First(e => e.Key.Equals(prop.Name, StringComparison.OrdinalIgnoreCase));
if (option == null)
{
//不存在该配置项,则清空当前值
prop.SetValue(null, Convert.ChangeType(null, prop.PropertyType), null);
}
else
{
prop.SetValue(null, Convert.ChangeType(option.Value, prop.PropertyType), null);
}
}
}