[Quantproject-developers] QuantProject/b1_ADT ExtendedDataTable.cs, 1.13, 1.14
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2011-08-21 09:57:35
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT
In directory vz-cvs-3.sog:/tmp/cvs-serv26025
Modified Files:
ExtendedDataTable.cs
Log Message:
Added some new methods for manipulating rows in DataTables
Index: ExtendedDataTable.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ExtendedDataTable.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ExtendedDataTable.cs 16 Jan 2011 19:50:23 -0000 1.13
--- ExtendedDataTable.cs 21 Aug 2011 09:57:33 -0000 1.14
***************
*** 116,132 ****
int numRows = table.Rows.Count;
double[] arrayOfDouble = new double[numRows];
! int index = 0;
! try
{
! for(; index!= numRows; index++)
! {
! arrayOfDouble[index] = (double) table.Rows[index][columnName];
}
!
! }
! catch(Exception ex)
! {
! string s = ex.ToString();
! index = numRows;
}
return arrayOfDouble;
--- 116,128 ----
int numRows = table.Rows.Count;
double[] arrayOfDouble = new double[numRows];
! for(int index = 0; index < numRows; index++)
{
! arrayOfDouble[index] = double.NaN;
! try{
! arrayOfDouble[index] = (double)table.Rows[index][columnName];
}
! catch(Exception ex){
! string s = ex.ToString();
! }
}
return arrayOfDouble;
***************
*** 277,287 ****
j = 0;
}
-
}
return hashTable;
-
}
!
}
}
--- 273,355 ----
j = 0;
}
}
return hashTable;
}
! #region GetArrayOfStringFromRows
! private static string getArrayOfStringFromRows_getColumnNames(DataTable table)
! {
! string returnValue = null;
! foreach(DataColumn dataColumn in table.Columns)
! returnValue = returnValue + dataColumn.ColumnName + "; ";
! return returnValue;
! }
!
! private static string getArrayOfStringFromRows_getRowValues(DataTable table,
! int currentRowIndex)
! {
! string returnValue = null;
! int numOfColumns = table.Columns.Count;
! for(int i = 0; i < numOfColumns; i++)
! returnValue = returnValue + table.Rows[currentRowIndex][i].ToString() + "; ";
! return returnValue;
! }
!
! /// <summary>
! /// Get an array of string (for debugging purposes):
! /// the string with index 0 contains the name of the columns of the
! /// data table;
! /// the other strings contain all the table's rows
! /// </summary>
! public static string[] GetArrayOfStringFromRows(DataTable table)
! {
! int numRows = table.Rows.Count;
! string[] arrayOfString = new string[numRows];
! int index = 0;
! try
! {
! for(; index!= numRows; index++)
! {
! if(index == 0)
! arrayOfString[index] = getArrayOfStringFromRows_getColumnNames(table);
! else
! arrayOfString[index] = getArrayOfStringFromRows_getRowValues(table, index);
! }
! }
! catch(Exception ex)
! {
! MessageBox.Show(ex.ToString());
! index = numRows;
! }
! return arrayOfString;
! }
! #endregion GetArrayOfStringFromRows
!
! /// <summary>
! /// Import in destinationTable all the rows in
! /// sourceTable.
! /// Destination and source tables have to share
! /// the same data - structure
! /// </summary>
! public static void ImportRowsFromFirstRowOfSource(DataTable sourceTable,
! DataTable destinationTable)
! {
! DataRow[] sourceRows = sourceTable.Select();
! for(int i = 0; i < sourceRows.Length; i++)
! destinationTable.ImportRow(sourceRows[i]);
! }
! /// <summary>
! /// Import in destinationTable all the rows in
! /// sourceTable.
! /// Destination and source tables have to share
! /// the same data - structure
! /// </summary>
! public static void ImportRowsFromLastRowOfSource(DataTable sourceTable,
! DataTable destinationTable)
! {
! DataRow[] sourceRows = sourceTable.Select();
! for(int i = sourceRows.Length - 1; i >= 0; i--)
! destinationTable.ImportRow(sourceRows[i]);
! }
}
}
|