| 1 |
|
|---|
| 2 | Class Trace
|
|---|
| 3 | Static indentLevel = 0 As Long
|
|---|
| 4 | Static indentSize = 4 As Long
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 | ' リスナ管理
|
|---|
| 8 | Static Listeners As TraceListenerCollection
|
|---|
| 9 |
|
|---|
| 10 | Public
|
|---|
| 11 |
|
|---|
| 12 | '----------------------------------------------------------------
|
|---|
| 13 | ' パブリック メソッド
|
|---|
| 14 | '----------------------------------------------------------------
|
|---|
| 15 |
|
|---|
| 16 | ' アサート(コールスタックを表示)
|
|---|
| 17 | Static Sub Assert( condition As Boolean )
|
|---|
| 18 | If condition == False then
|
|---|
| 19 | 'TODO: コールスタックを表示
|
|---|
| 20 | End If
|
|---|
| 21 | End Sub
|
|---|
| 22 |
|
|---|
| 23 | ' アサート(メッセージ文字列を表示)
|
|---|
| 24 | Static Sub Assert( condition As Boolean, message As String )
|
|---|
| 25 | If condition == False then
|
|---|
| 26 | ' TODO: メッセージボックス形式での表示に対応
|
|---|
| 27 | WriteLine( message )
|
|---|
| 28 | End If
|
|---|
| 29 | End Sub
|
|---|
| 30 |
|
|---|
| 31 | ' アサート(メッセージ文字列と詳細文字列を表示)
|
|---|
| 32 | Static Sub Assert( condition As Boolean, message As String, detailMessage As String )
|
|---|
| 33 | If condition == False then
|
|---|
| 34 | ' TODO: メッセージボックス形式での表示に対応
|
|---|
| 35 | WriteLine( message )
|
|---|
| 36 | End If
|
|---|
| 37 | End Sub
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | ' インデントレベルを上げる
|
|---|
| 41 | Static Sub Indent()
|
|---|
| 42 | IndentLevel = indentLevel + 1
|
|---|
| 43 | End Sub
|
|---|
| 44 |
|
|---|
| 45 | ' インデントレベルを下げる
|
|---|
| 46 | Static Sub Unindent()
|
|---|
| 47 | If indentLevel <= 0 Then
|
|---|
| 48 | indentLevel = 0
|
|---|
| 49 | Return
|
|---|
| 50 | End If
|
|---|
| 51 | IndentLevel = indentLevel - 1
|
|---|
| 52 | End Sub
|
|---|
| 53 |
|
|---|
| 54 | Static Sub Write( message As String )
|
|---|
| 55 |
|
|---|
| 56 | End Sub
|
|---|
| 57 |
|
|---|
| 58 | ' 一行の文字列を出力
|
|---|
| 59 | Static Sub WriteLine( message As String )
|
|---|
| 60 | Dim i As Long
|
|---|
| 61 | For i = 0 To ELM( Listeners.Count )
|
|---|
| 62 | Dim temp As TraceListener
|
|---|
| 63 | temp = Listeners[i]
|
|---|
| 64 | temp.WriteLine( message )
|
|---|
| 65 | Next
|
|---|
| 66 | End Sub
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | '----------------------------------------------------------------
|
|---|
| 70 | ' パブリック プロパティ
|
|---|
| 71 | '----------------------------------------------------------------
|
|---|
| 72 |
|
|---|
| 73 | ' IndentLevelプロパティ
|
|---|
| 74 | Static Function IndentLevel() As Long
|
|---|
| 75 | Return indentLevel
|
|---|
| 76 | End Function
|
|---|
| 77 | Static Sub IndentLevel( indentLevel As Long )
|
|---|
| 78 | This.indentLevel = indentLevel
|
|---|
| 79 |
|
|---|
| 80 | Dim i As Long
|
|---|
| 81 | For i = 0 To ELM( Listeners.Count )
|
|---|
| 82 | Dim temp As TraceListener
|
|---|
| 83 | temp = Listeners[i]
|
|---|
| 84 | temp.IndentLevel = indentLevel
|
|---|
| 85 | Next
|
|---|
| 86 | End Sub
|
|---|
| 87 |
|
|---|
| 88 | ' IndentSizeプロパティ
|
|---|
| 89 | Static Function IndentSize() As Long
|
|---|
| 90 | Return indentSize
|
|---|
| 91 | End Function
|
|---|
| 92 | Static Sub IndentSize( size As Long )
|
|---|
| 93 | indentSize = size
|
|---|
| 94 |
|
|---|
| 95 | Dim i As Long
|
|---|
| 96 | For i = 0 To ELM( Listeners.Count )
|
|---|
| 97 | Dim temp As TraceListener
|
|---|
| 98 | temp = Listeners[i]
|
|---|
| 99 | temp.IndentSize = indentSize
|
|---|
| 100 | Next
|
|---|
| 101 | End Sub
|
|---|
| 102 |
|
|---|
| 103 | End Class
|
|---|
| 104 |
|
|---|
| 105 | Dim _System_defaultTraceListener As DefaultTraceListener
|
|---|
| 106 | Trace.Listeners.Add( _System_defaultTraceListener )
|
|---|