本文整理汇总了VB.NET中System.Diagnostics.Switch类的典型用法代码示例。如果您正苦于以下问题:VB.NET Switch类的具体用法?VB.NET Switch怎么用?VB.NET Switch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Switch类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1:
' The following are possible values for the new switch.
Public Enum MethodTracingSwitchLevel
Off = 0
EnteringMethod = 1
ExitingMethod = 2
Both = 3
End Enum 'MethodTracingSwitchLevel
示例2: MyMethodTracingSwitch
Public Class MyMethodTracingSwitch
Inherits Switch
Protected outExit As Boolean
Protected outEnter As Boolean
Protected myLevel As MethodTracingSwitchLevel
Public Sub New(displayName As String, description As String)
MyBase.New(displayName, description)
End Sub
Public Property Level() As MethodTracingSwitchLevel
Get
Return myLevel
End Get
Set
SetSwitchSetting(CInt(value))
End Set
End Property
Protected Sub SetSwitchSetting(value As Integer)
If value < 0 Then
value = 0
End If
If value > 3 Then
value = 3
End If
myLevel = CType(value, MethodTracingSwitchLevel)
outEnter = False
If value = CInt(MethodTracingSwitchLevel.EnteringMethod) Or _
value = CInt(MethodTracingSwitchLevel.Both) Then
outEnter = True
End If
outExit = False
If value = CInt(MethodTracingSwitchLevel.ExitingMethod) Or _
value = CInt(MethodTracingSwitchLevel.Both) Then
outExit = True
End If
End Sub
Public ReadOnly Property OutputExit() As Boolean
Get
Return outExit
End Get
End Property
Public ReadOnly Property OutputEnter() As Boolean
Get
Return outEnter
End Get
End Property
End Class
示例3: Class1
Public Class Class1
' Create an instance of MyMethodTracingSwitch.
Private Shared mySwitch As New _
MyMethodTracingSwitch("Methods", "Trace entering and exiting method")
Public Shared Sub Main()
' Add the console listener to see trace messages as console output
Trace.Listeners.Add(New ConsoleTraceListener(True))
Debug.AutoFlush = True
' Set the switch level to both enter and exit
mySwitch.Level = MethodTracingSwitchLevel.Both
' Write a diagnostic message if the switch is set to entering.
Debug.WriteLineIf(mySwitch.OutputEnter, "Entering Main")
' Insert code to handle processing here...
' Write another diagnostic message if the switch is set to exiting.
Debug.WriteLineIf(mySwitch.OutputExit, "Exiting Main")
End Sub
End Class