BooleanSwitch 생성자

정의

BooleanSwitch 클래스의 새 인스턴스를 초기화합니다.

오버로드

BooleanSwitch(String, String)

지정된 표시 이름 및 설명을 사용하여 BooleanSwitch 클래스의 새 인스턴스를 초기화합니다.

BooleanSwitch(String, String, String)

지정된 표시 이름, 설명 및 기본 스위치 값을 사용하여 BooleanSwitch 클래스의 새 인스턴스를 초기화합니다.

BooleanSwitch(String, String)

Source:
BooleanSwitch.cs
Source:
BooleanSwitch.cs
Source:
BooleanSwitch.cs

지정된 표시 이름 및 설명을 사용하여 BooleanSwitch 클래스의 새 인스턴스를 초기화합니다.

public:
 BooleanSwitch(System::String ^ displayName, System::String ^ description);
public BooleanSwitch (string displayName, string? description);
public BooleanSwitch (string displayName, string description);
new System.Diagnostics.BooleanSwitch : string * string -> System.Diagnostics.BooleanSwitch
Public Sub New (displayName As String, description As String)

매개 변수

displayName
String

사용자 인터페이스에 표시할 이름입니다.

description
String

스위치에 대한 설명입니다.

예제

다음 예제에서는 BooleanSwitch 스위치를 사용 하는 오류 메시지를 출력할 것인지 여부를 결정 합니다. 스위치는 클래스 수준에서 생성 됩니다. 합니다 Main 메서드를 위치로 전달 MyMethod오류 메시지를 인쇄 하 고 오류가 발생 합니다.

public ref class BooleanSwitchTest
{
private:

   /* Create a BooleanSwitch for data.*/
   static BooleanSwitch^ dataSwitch = gcnew BooleanSwitch( "Data","DataAccess module" );

public:
   static void MyMethod( String^ location )
   {
      
      //Insert code here to handle processing.
      if ( dataSwitch->Enabled )
            Console::WriteLine( "Error happened at {0}", location );
   }

};

int main()
{
   
   //Run the method which writes an error message specifying the location of the error.
   BooleanSwitchTest::MyMethod( "in main" );
}
// Class level declaration.
/* Create a BooleanSwitch for data.*/
static BooleanSwitch dataSwitch = new BooleanSwitch("Data", "DataAccess module");

static public void MyMethod(string location)
{
    //Insert code here to handle processing.
    if (dataSwitch.Enabled)
        Console.WriteLine("Error happened at " + location);
}

public static void Main(string[] args)
{
    //Run the method which writes an error message specifying the location of the error.
    MyMethod("in Main");
}
' 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

' Entry point which delegates to C-style main function.
Public Overloads Shared Sub Main()
    Main(System.Environment.GetCommandLineArgs())
End Sub
 
Overloads Public Shared Sub Main(args() As String)
    ' Run the method which writes an error message specifying the location of the error.
    MyMethod("in Main")
End Sub

설명

BooleanSwitchdisplayName 만들 때 매개 변수는 애플리케이션 구성 파일에서 .NET Framework 앱에 대한 초기 스위치 설정을 찾는 데 사용됩니다. 생성자가 초기 설정을 찾을 수 없거나 .NET Core 및 .NET 5+ 앱의 Enabled 경우 속성이 (사용 안 함)으로 false 설정됩니다.

.NET Framework 앱에서 수준을 BooleanSwitch 설정하려면 애플리케이션 이름에 해당하는 구성 파일을 편집합니다. 이 파일에서 스위치를 추가 하 고 해당 값을 설정, 스위치를 제거 하거나 지울 수 애플리케이션에서 이전에 설정한 모든 스위치입니다. 다음 예제와 같이 구성 파일의 형식은 해야 합니다.

<configuration>  
    <system.diagnostics>  
       <switches>  
          <add name="mySwitch" value="10" />  
          <add name="myNewSwitch" value="20" />  
          <remove name="mySwitch" />  
          <clear/>  
       </switches>  
    </system.diagnostics>  
 </configuration>  

참고

사용자가 만든 스위치 해야 static합니다.

추가 정보

적용 대상

BooleanSwitch(String, String, String)

Source:
BooleanSwitch.cs
Source:
BooleanSwitch.cs
Source:
BooleanSwitch.cs

지정된 표시 이름, 설명 및 기본 스위치 값을 사용하여 BooleanSwitch 클래스의 새 인스턴스를 초기화합니다.

public:
 BooleanSwitch(System::String ^ displayName, System::String ^ description, System::String ^ defaultSwitchValue);
public BooleanSwitch (string displayName, string? description, string defaultSwitchValue);
public BooleanSwitch (string displayName, string description, string defaultSwitchValue);
new System.Diagnostics.BooleanSwitch : string * string * string -> System.Diagnostics.BooleanSwitch
Public Sub New (displayName As String, description As String, defaultSwitchValue As String)

매개 변수

displayName
String

사용자 인터페이스에 표시할 이름입니다.

description
String

스위치에 대한 설명입니다.

defaultSwitchValue
String

스위치의 기본값입니다.

적용 대상