Beispiel #1
0
        public void SetDataRowBuildersSetsCorrectNumberOfProperties()
        {
            IToDataTableContext dataTableContext = ToDataTableContext.Instance;
            var result = dataTableContext.SetDataRowBuilders <TestClass>(TypeDescriptor.GetProperties(typeof(TestClass)));

            result.Count().Should().Be(14);
        }
        internal static DataTable ToDataTable <T>(IEnumerable <T> enumerable, IToDataTableContext toDataTableContext)
        {
            var dataRowBuilders = toDataTableContext.GetDataRowBuilders <T>() ??
                                  toDataTableContext.SetDataRowBuilders <T>(TypeDescriptor.GetProperties(typeof(T)));

            var table = CreateDataTable(dataRowBuilders);

            foreach (var item in enumerable)
            {
                AddDataRow(table, dataRowBuilders, item);
            }

            return(table);
        }