一个自定义的console输出类(test)
为了显示工作流的运行情况,写了一个test类,该类就简单的实现了console.write的字串排版功能,可以改写他将内容存入数据库或磁盘文件.很多例子中用了该类,就将他贴出来了
'■△▲↑↓◆◇◎●○☆★□┌┐│└┘─∧∧∧∨∨∨⊙【】
Public Class test
Shared line As Integer = 0
Shared Sub New()
Console.BufferWidth = 140
Console.Title = "工作流调试器[引擎运行结果输出窗口]"
End Sub
Public Shared Sub 实例输出(ByVal 结点 As String, ByVal 事件 As String, ByVal 内容 As String)
自定义("工作流(结点)", "结点" + 结点 + ":" + "事件" + 事件, 内容, ConsoleColor.Red)
End Sub
Public Shared Sub 实例输出(ByVal 结点 As String, ByVal 事件 As String, ByVal 内容 As Collections.ArrayList)
自定义("工作流(结点)", "结点" + 结点 + ":" + "事件" + 事件, 内容, ConsoleColor.Red)
End Sub
Public Shared Sub 实例完成(ByVal guid As String)
自定义("工作流(结点)", "实例已完成", guid, ConsoleColor.Red)
End Sub
Public Shared Sub 实例完成(ByVal guid As String, ByVal 内容 As Collections.ArrayList)
自定义("工作流(结点)", "实例已完成" + vbCrLf + "│" + guid, 内容, ConsoleColor.Red)
End Sub
Public Shared Sub 宿主(ByVal 源 As String, ByVal 内容 As String)
自定义("宿主", 源, 内容, ConsoleColor.Cyan)
End Sub
Public Shared Sub 宿主(ByVal 源 As String, ByVal 内容 As Collections.ArrayList)
自定义("宿主", 源, 内容, ConsoleColor.Cyan)
End Sub
Public Shared Sub 跟踪(ByVal 源 As String, ByVal 内容 As String)
自定义("跟踪", 源, 内容, ConsoleColor.Yellow)
End Sub
Public Shared Sub 跟踪(ByVal 源 As String, ByVal 内容 As Collections.ArrayList)
自定义("跟踪", 源, 内容, ConsoleColor.Yellow)
End Sub
Public Shared Sub 持久化(ByVal 源 As String, ByVal 内容 As String)
自定义("持久化", 源, 内容, ConsoleColor.Green)
End Sub
Public Shared Sub 持久化(ByVal 源 As String, ByVal 内容 As Collections.ArrayList)
自定义("持久化", 源, 内容, ConsoleColor.Green)
End Sub
Public Shared Sub 自定义(ByVal 头 As String, ByVal 源 As String, ByVal 内容 As String, ByVal 颜色 As ConsoleColor)
Console.ForegroundColor = 颜色
test.头(头)
test.身(源)
test.身(内容)
test.尾()
End Sub
Public Shared Sub 自定义(ByVal 头 As String, ByVal 源 As String, ByVal 内容 As Collections.ArrayList, ByVal 颜色 As ConsoleColor)
Console.ForegroundColor = 颜色
test.头(头)
test.身(源)
If 内容 IsNot Nothing Then
For Each temp As Object In 内容
test.身(temp.ToString())
Next
Else
test.身("内容为空")
End If
test.尾()
End Sub
Shared Sub 头(ByVal v As String)
line = line + 1
Console.WriteLine(line)
Console.WriteLine("┌───────────────────────────────────────────────────────────────┐")
Console.WriteLine("│【" + v + "】" + DateTime.Now.ToString)
test.换行()
End Sub
Shared Sub 尾()
Console.WriteLine("└───────────────────────────────────────────────────────────────┘")
Console.WriteLine()
Console.ForegroundColor = ConsoleColor.White
End Sub
Shared Sub 身(ByVal v As String)
Console.WriteLine("│" + v)
End Sub
Shared Sub 换行()
Console.WriteLine("│")
End Sub
Public Shared Sub 清屏()
Console.Clear()
line = 0
End Sub
End Class
Public Class test
Shared line As Integer = 0
Shared Sub New()
Console.BufferWidth = 140
Console.Title = "工作流调试器[引擎运行结果输出窗口]"
End Sub
Public Shared Sub 实例输出(ByVal 结点 As String, ByVal 事件 As String, ByVal 内容 As String)
自定义("工作流(结点)", "结点" + 结点 + ":" + "事件" + 事件, 内容, ConsoleColor.Red)
End Sub
Public Shared Sub 实例输出(ByVal 结点 As String, ByVal 事件 As String, ByVal 内容 As Collections.ArrayList)
自定义("工作流(结点)", "结点" + 结点 + ":" + "事件" + 事件, 内容, ConsoleColor.Red)
End Sub
Public Shared Sub 实例完成(ByVal guid As String)
自定义("工作流(结点)", "实例已完成", guid, ConsoleColor.Red)
End Sub
Public Shared Sub 实例完成(ByVal guid As String, ByVal 内容 As Collections.ArrayList)
自定义("工作流(结点)", "实例已完成" + vbCrLf + "│" + guid, 内容, ConsoleColor.Red)
End Sub
Public Shared Sub 宿主(ByVal 源 As String, ByVal 内容 As String)
自定义("宿主", 源, 内容, ConsoleColor.Cyan)
End Sub
Public Shared Sub 宿主(ByVal 源 As String, ByVal 内容 As Collections.ArrayList)
自定义("宿主", 源, 内容, ConsoleColor.Cyan)
End Sub
Public Shared Sub 跟踪(ByVal 源 As String, ByVal 内容 As String)
自定义("跟踪", 源, 内容, ConsoleColor.Yellow)
End Sub
Public Shared Sub 跟踪(ByVal 源 As String, ByVal 内容 As Collections.ArrayList)
自定义("跟踪", 源, 内容, ConsoleColor.Yellow)
End Sub
Public Shared Sub 持久化(ByVal 源 As String, ByVal 内容 As String)
自定义("持久化", 源, 内容, ConsoleColor.Green)
End Sub
Public Shared Sub 持久化(ByVal 源 As String, ByVal 内容 As Collections.ArrayList)
自定义("持久化", 源, 内容, ConsoleColor.Green)
End Sub
Public Shared Sub 自定义(ByVal 头 As String, ByVal 源 As String, ByVal 内容 As String, ByVal 颜色 As ConsoleColor)
Console.ForegroundColor = 颜色
test.头(头)
test.身(源)
test.身(内容)
test.尾()
End Sub
Public Shared Sub 自定义(ByVal 头 As String, ByVal 源 As String, ByVal 内容 As Collections.ArrayList, ByVal 颜色 As ConsoleColor)
Console.ForegroundColor = 颜色
test.头(头)
test.身(源)
If 内容 IsNot Nothing Then
For Each temp As Object In 内容
test.身(temp.ToString())
Next
Else
test.身("内容为空")
End If
test.尾()
End Sub
Shared Sub 头(ByVal v As String)
line = line + 1
Console.WriteLine(line)
Console.WriteLine("┌───────────────────────────────────────────────────────────────┐")
Console.WriteLine("│【" + v + "】" + DateTime.Now.ToString)
test.换行()
End Sub
Shared Sub 尾()
Console.WriteLine("└───────────────────────────────────────────────────────────────┘")
Console.WriteLine()
Console.ForegroundColor = ConsoleColor.White
End Sub
Shared Sub 身(ByVal v As String)
Console.WriteLine("│" + v)
End Sub
Shared Sub 换行()
Console.WriteLine("│")
End Sub
Public Shared Sub 清屏()
Console.Clear()
line = 0
End Sub
End Class