/// <summary> /// Create a clone. /// </summary> public FormatColumn(FormatColumn other) : base(other) { this.Require(x => other != null); Name = other.Name; }
/// <summary> /// Create a clone. /// </summary> public FormatColumn( FormatColumn other ) : base(other) { this.Require( x => other != null ); Name = other.Name; }
public void Copy() { FormatColumn col = new FormatColumn( "test", typeof( int ), "000.000" ); FormatColumn col2 = new FormatColumn( col ); Assert.AreEqual( "test", col2.Name ); Assert.AreEqual( typeof( int ), col2.Type ); Assert.AreEqual( "000.000", col2.Format ); }
public void Create() { FormatColumn col = new FormatColumn( "test" ); Assert.AreEqual( "test", col.Name ); Assert.IsNull( col.Format ); Assert.AreEqual( typeof( string ), col.Type ); col = new FormatColumn( "test", typeof( int ) ); Assert.AreEqual( typeof( int ), col.Type ); col = new FormatColumn( "test", typeof( int ), "000.000" ); Assert.AreEqual( "000.000", col.Format ); }
public void ToFormattedTable(DataTable rawTable, DataTable targetTable) { for (int r = 0; r < rawTable.Rows.Count; ++r) { if (SkipRows.Contains(r)) { continue; } DataRow rawRow = rawTable.Rows[r]; DataRow row = targetTable.NewRow(); int targetCol = 0; bool isEmpty = true; for (int c = 0; c < rawRow.ItemArray.Length; ++c) { if (SkipColumns.Contains(c)) { continue; } if (targetCol == Columns.Length) { break; } FormatColumn formatCol = Columns[targetCol]; object value = formatCol.Convert(rawRow[c].ToString()); row[formatCol.Name] = (value != null ? value : DBNull.Value); if (row[formatCol.Name] != DBNull.Value) { isEmpty = false; } targetCol++; } if (!isEmpty) { targetTable.Rows.Add(row); } } }
public void CreateInvalid() { FormatColumn col = new FormatColumn( (string)null ); }
public void CopyNull() { FormatColumn col = new FormatColumn( (FormatColumn)null ); }