Beispiel #1
0
        /// <summary>
        /// Create a clone.
        /// </summary>
        public FormatColumn(FormatColumn other)
            : base(other)
        {
            this.Require(x => other != null);

            Name = other.Name;
        }
Beispiel #2
0
        /// <summary>
        /// Create a clone.
        /// </summary>
        public FormatColumn( FormatColumn other )
            : base(other)
        {
            this.Require( x => other != null );

            Name = other.Name;
        }
Beispiel #3
0
        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 );
        }
Beispiel #4
0
        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 );
        }
Beispiel #5
0
        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);
                }
            }
        }
Beispiel #6
0
 public void CreateInvalid()
 {
     FormatColumn col = new FormatColumn( (string)null );
 }
Beispiel #7
0
 public void CopyNull()
 {
     FormatColumn col = new FormatColumn( (FormatColumn)null );
 }