private static IEnumerable <DataColumn> ExtranctDataColumns(BaseInfo info) { var type = info.GetType(); return(from c in info.ColumnNames let prop = type.GetProperty(c) where prop != null select new DataColumn(c, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType)); }
public Info(BaseInfo info, int index, Group parent) { if (info == null) { throw new ArgumentNullException("info"); } BaseInfo = info; Iter = new TreeIter() { UserData = (IntPtr)GCHandle.Alloc(this) }; Index = index; Parent = parent; _Children = new Lazy <IReadOnlyList <Group> > (() => { var childGroups = new List <InfoGrouping> (); foreach (var property in info.GetType().GetProperties()) { if (typeof(IEnumerable <BaseInfo>).IsAssignableFrom(property.PropertyType)) { childGroups.Add(new InfoGrouping(property.Name, (IEnumerable <BaseInfo>)property.GetValue(info))); } else if (typeof(TypeInfo).IsAssignableFrom(property.PropertyType)) { // type info will be show with parent continue; } else if (typeof(PropertyInfo).IsAssignableFrom(property.PropertyType)) { var value = (BaseInfo)property.GetValue(info); childGroups.Add(new InfoGrouping(property.Name, value == null ? new BaseInfo[] { } : new [] { value })); } } return(recursiveAddGroupings(childGroups, this)); }); }
private static IEnumerable<DataColumn> ExtractDataColumns(BaseInfo info) { var type = info.GetType(); return from c in info.ColumnNames let prop = type.GetProperty(c) where prop != null select new DataColumn(c, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType); }