本文整理匯總了VB.NET中System.AppContext.TryGetSwitch方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET AppContext.TryGetSwitch方法的具體用法?VB.NET AppContext.TryGetSwitch怎麽用?VB.NET AppContext.TryGetSwitch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.AppContext
的用法示例。
在下文中一共展示了AppContext.TryGetSwitch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: AmazingLib
Public Class AmazingLib
Private shouldThrow As Boolean
Public Sub PerformAnOperation()
If Not AppContext.TryGetSwitch("Switch.AmazingLib.ThrowOnException", shouldThrow) Then
' This is the case where the switch value was not set by the application.
' The library can choose to get the value of shouldThrow by other means.
' If no overrides or default values are specified, the value should be 'false'.
' A false value implies the latest behavior.
End If
' The library can use the value of shouldThrow to throw exceptions or not.
If shouldThrow Then
' old code
Else
' new code
End If
End Sub
End Class