/// <summary> /// Creates the rows from the data. /// </summary> protected virtual void CreateDataRows() { _adapter = DataSourceAdapter <TItem> .CreateAdapter(_dataSource); foreach (TItem item in _adapter.GetEnumerator()) { ushort column = 0; Row row = CurrentWorksheet.Rows.AddRow((ushort)(CurrentWorksheet.Rows.Count + 1)); foreach (var field in _fields) { Cell cell = CurrentWorksheet.Cells.Add(row.RowIndex, ++column, GetRowValue(item, field)); field.OnBoundField(this, cell, row, item); } OnRowDataBound(row, item); } }
public void CreateSupported() { KeyValuePair <object, Type>[] dataSources = new KeyValuePair <object, Type>[] { new KeyValuePair <object, Type>(new List <DataSourceAdapterTest>(), typeof(IEnumerable)), new KeyValuePair <object, Type>(new TestDataReader(), typeof(IDataReader)), new KeyValuePair <object, Type>(new DataTable(), typeof(DataTable)), new KeyValuePair <object, Type>(new ObjectDataSource(), typeof(ObjectDataSource)) }; foreach (KeyValuePair <object, Type> pair in dataSources) { DataSourceAdapter <DataSourceAdapterTest> adapter = DataSourceAdapter <DataSourceAdapterTest> .CreateAdapter(pair.Key); Console.WriteLine("DataSource Type: {0}, Adapter Type: {1}", pair.Key.GetType().Name, adapter.GetType().Name); Assert.IsNotNull(adapter); Assert.AreEqual(SupportedTypes[pair.Value], adapter.GetType()); } }
public void CreateNotSupported() { DataSourceAdapter <object> adapter = DataSourceAdapter <object> .CreateAdapter(new object()); }