public static IDataReader AsDataReader(this IEnumerable collection) { var e = new ChoStdDeferedObjectMemberDiscoverer(collection); var dr = new ChoEnumerableDataReader(e.AsEnumerable(), e); return(dr); }
public static IDataReader AsDataReader(this IEnumerable collection, Action <IDictionary <string, Type> > membersDiscovered = null) { var e = new ChoStdDeferedObjectMemberDiscoverer(collection); if (membersDiscovered != null) { e.MembersDiscovered += (o, e1) => { membersDiscovered(e1.Value); }; } var dr = new ChoEnumerableDataReader(e.AsEnumerable(), e); return(dr); }
public static IDataReader AsDataReader(this IEnumerable collection, Action <IDictionary <string, Type> > membersDiscovered = null, string[] selectedFields = null, string[] excludeFields = null) { var e = new ChoStdDeferedObjectMemberDiscoverer(collection); if (membersDiscovered != null) { e.MembersDiscovered += (o, e1) => { membersDiscovered(e1.Value); }; } else { e.MembersDiscovered += (o, e1) => { if (excludeFields != null) { foreach (var ef in excludeFields) { if (e1.Value.ContainsKey(ef)) { e1.Value.Remove(ef); } } } else if (selectedFields != null) { foreach (var sf in e1.Value.Keys.Except(selectedFields).ToArray()) { e1.Value.Remove(sf); } } }; } var dr = new ChoEnumerableDataReader(e.AsEnumerable(), e); return(dr); }