private static object ToObject(Type t, IDictionary <string, object> dict, bool safe, bool parse) { var tree = new NameTree(dict.Keys); var children = dict.Keys.Count == 1 ? (IEnumerable <NameNode>) new[] { tree.Root } : tree.Root.Children; return(ToObject(t, dict, children, safe, parse)); }
private static IEnumerable <T> ToObject <T>(DataTable table, bool safe) { if (table == null) { throw new ArgumentNullException("table"); } var names = table.Columns.OfType <DataColumn>().Select(c => c.ColumnName); var tree = new NameTree(names); var children = names.Count() == 1 ? (IEnumerable <NameNode>) new[] { tree.Root } : tree.Root.Children; foreach (DataRow row in table.Rows) { yield return((T)ToObject(typeof(T), ToDictionary(row), children, safe, false)); } }