public void ExportElement(IExportElement element, DataSet ds) { Type type = element.GetType(); DataTable dt = ds.Tables[type.Name]; if (dt == null) { throw new Exception("数据集中找不到对应表:" + type.Name); } DataRow dr = dt.NewRow(); PropertyInfo[] props = type.GetProperties(); if (props == null || props.Length == 0) { return; } foreach (PropertyInfo pro in props) { if (IsExport(pro)) { FillDataColumn(pro, dr, element); } } dt.Rows.Add(dr); }
private void SetProperty(string propName, object value, IExportElement element) { try { PropertyInfo pro = element.GetType().GetProperty(propName); if (pro != null) { pro.SetValue(element, value, null); } } catch (Exception ex) { throw ex; } }
private void FillCustom(CustomElement custom, IExportElement data) { PropertyInfo[] props = data.GetType().GetProperties(); foreach (PropertyInfo prop in props) { PropertyInfo prop1 = custom.GetType().GetProperty(prop.Name); if (prop1 != null) { prop.SetValue(data, prop1.GetValue(custom), null); } } }