1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.Data;
|
21
|
|
using System.Diagnostics;
|
22
|
|
using System.Reflection;
|
23
|
|
using System.Text;
|
24
|
|
using Seasar.Framework.Log;
|
25
|
|
|
26
|
|
namespace Seasar.Framework.Util
|
27
|
|
{
|
28
|
|
public class DataTableInspector
|
29
|
|
{
|
30
|
|
private static readonly Logger Log = Logger.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
31
|
|
|
32
|
0
|
private DataTableInspector()
|
33
|
|
{
|
34
|
|
}
|
35
|
|
|
36
|
20
|
public static string ToString(DataTable dataTable)
|
37
|
|
{
|
38
|
20
|
StringBuilder result = new StringBuilder();
|
39
|
|
|
40
|
20
|
result.AppendFormat("{0}\r\n", dataTable.TableName);
|
41
|
|
|
42
|
20
|
DataRowCollection tableRows = dataTable.Rows;
|
43
|
20
|
DataColumnCollection tableColumns = dataTable.Columns;
|
44
|
|
|
45
|
97
|
for (int ctrRow = 0; ctrRow < tableRows.Count; ctrRow++)
|
46
|
|
{
|
47
|
77
|
DataRow row = tableRows[ctrRow] as DataRow;
|
48
|
77
|
result.AppendFormat("Row #{0}-\r\n", ctrRow + 1);
|
49
|
77
|
object[] rowItems = row.ItemArray;
|
50
|
|
|
51
|
535
|
for (int ctrColumn = 0; ctrColumn < tableColumns.Count; ctrColumn++)
|
52
|
|
{
|
53
|
458
|
DataColumn column = tableColumns[ctrColumn] as DataColumn;
|
54
|
458
|
result.AppendFormat("\t{0}: {1}\r\n", column.ColumnName,
|
55
|
|
rowItems[ctrColumn].ToString());
|
56
|
|
}
|
57
|
|
}
|
58
|
20
|
result.Append("\r\n");
|
59
|
20
|
return result.ToString();
|
60
|
|
}
|
61
|
|
|
62
|
0
|
public static void DebugLog(DataTable dataTable, string header)
|
63
|
|
{
|
64
|
|
string output = string.Format("{0}\r\n{1}", header,
|
65
|
|
DataTableInspector.ToString(dataTable));
|
66
|
|
Log.Debug(output);
|
67
|
|
}
|
68
|
|
|
69
|
0
|
public static void DebugLog(DataTable dataTable)
|
70
|
|
{
|
71
|
|
Log.Debug(DataTableInspector.ToString(dataTable));
|
72
|
|
}
|
73
|
|
|
74
|
0
|
public static void DebugWriteLine(DataTable dataTable, string header)
|
75
|
|
{
|
76
|
|
string output = string.Format("{0}\r\n{1}", header,
|
77
|
|
DataTableInspector.ToString(dataTable));
|
78
|
|
Debug.WriteLine(output);
|
79
|
|
}
|
80
|
|
|
81
|
0
|
public static void DebugWriteLine(DataTable dataTable)
|
82
|
|
{
|
83
|
|
Debug.WriteLine(DataTableInspector.ToString(dataTable));
|
84
|
|
}
|
85
|
|
|
86
|
0
|
public static void OutWriteLine(DataTable dataTable, string header)
|
87
|
|
{
|
88
|
|
string output = string.Format("{0}\r\n{1}", header,
|
89
|
|
DataTableInspector.ToString(dataTable));
|
90
|
|
Console.Out.WriteLine(output);
|
91
|
|
}
|
92
|
|
|
93
|
8
|
public static void OutWriteLine(DataTable dataTable)
|
94
|
|
{
|
95
|
8
|
Console.Out.WriteLine(DataTableInspector.ToString(dataTable));
|
96
|
|
}
|
97
|
|
|
98
|
0
|
public static void TraceWriteLine(DataTable dataTable, string header)
|
99
|
|
{
|
100
|
|
string output = string.Format("{0}\r\n{1}", header,
|
101
|
|
DataTableInspector.ToString(dataTable));
|
102
|
|
Trace.WriteLine(output);
|
103
|
|
}
|
104
|
|
|
105
|
0
|
public static void TraceWriteLine(DataTable dataTable)
|
106
|
|
{
|
107
|
|
Trace.WriteLine(DataTableInspector.ToString(dataTable));
|
108
|
|
}
|
109
|
|
}
|
110
|
|
}
|