Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Propiedad BooleanSwitch.Enabled

 

Publicado: octubre de 2016

Obtiene o establece un valor que indica si el modificador está habilitado o deshabilitado.

Espacio de nombres:   System.Diagnostics
Ensamblado:  System (en System.dll)

Public Property Enabled As Boolean

Valor de propiedad

Type: System.Boolean

true si el modificador está habilitado; de lo contrario, false. De manera predeterminada, es false.

Exception Condition
SecurityException

El autor de llamada no dispone del permiso requerido.

By default, this field is set to false (disabled). To enable the switch, assign this field the value of true. To disable the switch, assign the value to false. The value of this property is determined by the value of the base class property P:System.Diagnostics.Switch.SwitchSetting.

System_CAPS_noteNota

This method uses the F:System.Security.Permissions.SecurityAction.LinkDemand flag to prevent being called from untrusted code; only the immediate caller is required to have P:System.Security.Permissions.SecurityPermissionAttribute.UnmanagedCode permission. If your code can be called from partially trusted code, do not pass the user input to T:System.Runtime.InteropServices.Marshal class methods without validation.

The following code example creates a T:System.Diagnostics.BooleanSwitch and uses the switch to determine whether to print an error message. The switch is created at the class level. The Main method passes its location to MyMethod, which prints an error message and the location where the error occurred.

'Class level declaration.
' Create a BooleanSwitch for data. 
Private Shared dataSwitch As New BooleanSwitch("Data", "DataAccess module")


Public Shared Sub MyMethod(location As String)
    'Insert code here to handle processing.
    If dataSwitch.Enabled Then
        Console.WriteLine(("Error happened at " + location))
    End If
End Sub 'MyMethod

'Entry point which delegates to C-style main Private Function
Public Overloads Shared Sub Main()
    Main(System.Environment.GetCommandLineArgs())
End Sub

Overloads Public Shared Sub Main(args() As String)
    'Run the method that writes an error message specifying the location of the error.
    MyMethod("in Main")
End Sub 'Main

SecurityPermission

for operating with unmanaged code. Demand value F:System.Security.Permissions.SecurityAction.LinkDemand; Associated enumeration: F:System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode.

.NET Framework
Disponible desde 1.1
Volver al principio
Mostrar: