static void SetPropertyValue(PrintOrderForm.LineInfo info, string strKeyName, object value) { try { info.GetType().GetProperty(strKeyName).SetValue(info, value); } catch (Exception ex) { throw new Exception($"SetProperty() 时发生异常(strKeyName={strKeyName} value={value}): " + ex.Message); } }
static object GetPropertyValue(PrintOrderForm.LineInfo info, string strKeyName) { object result = info.GetType().GetProperty(strKeyName).GetValue(info); return(result); #if NO if (strKeyName == "seller") { return(info.Seller); } else if (strKeyName == "source") { return(info.Source); } throw new ArgumentException($"未知的 strKeyName '{strKeyName}'"); #endif }