public static DataTable ToDataTable(this IEnumerable <DbObject> dbObjects) { if (dbObjects == null) { return(null); } DbObject component = dbObjects.FirstOrDefault <DbObject>(); if (component == null) { return(null); } PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component); DataTable table = new DataTable(); foreach (PropertyDescriptor descriptor in properties) { table.Columns.Add(descriptor.Name, descriptor.PropertyType); } foreach (DbObject obj3 in dbObjects) { DataRow row = table.NewRow(); foreach (PropertyDescriptor descriptor2 in properties) { bool flag; row[descriptor2.Name] = obj3.GetDataInternal(descriptor2.Name, out flag); } table.Rows.Add(row); } return(table); }
public void CopyTo(DbObject obj) { string[] allDataNames = this.GetAllDataNames(); lock (obj._slot.SyncRoot) { foreach (string str in allDataNames) { bool flag; obj.SetDataInternal(str, this.GetDataInternal(str, out flag)); } } }
public override void SetValue(object component, object value) { DbObject obj2 = component as DbObject; if ((obj2 != null) && obj2.ContainData(this.Name)) { obj2.SetDataInternal(this.Name, value); } else { PropertyInfo property = component.GetType().GetProperty(this.Name); if (property != null) { property.SetValue(component, value, null); } } this.OnValueChanged(component, EventArgs.Empty); }
public override object GetValue(object component) { DbObject obj2 = component as DbObject; if (obj2 != null) { bool flag; object dataInternal = obj2.GetDataInternal(this.Name, out flag); if (flag) { return(dataInternal); } } PropertyInfo property = component.GetType().GetProperty(this.Name); if (property != null) { return(property.GetValue(component, null)); } return(null); }