SwitchAttribute.GetAll(Assembly) Metode

Definisi

Mengembalikan semua atribut switch untuk rakitan yang ditentukan.

public:
 static cli::array <System::Diagnostics::SwitchAttribute ^> ^ GetAll(System::Reflection::Assembly ^ assembly);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types may be trimmed from the assembly.")]
public static System.Diagnostics.SwitchAttribute[] GetAll(System.Reflection.Assembly assembly);
public static System.Diagnostics.SwitchAttribute[] GetAll(System.Reflection.Assembly assembly);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types may be trimmed from the assembly.")>]
static member GetAll : System.Reflection.Assembly -> System.Diagnostics.SwitchAttribute[]
static member GetAll : System.Reflection.Assembly -> System.Diagnostics.SwitchAttribute[]
Public Shared Function GetAll (assembly As Assembly) As SwitchAttribute()

Parameter

assembly
Assembly

Rakitan untuk memeriksa atribut switch.

Mengembalikan

Array yang berisi semua atribut switch untuk assembly.

Atribut

Pengecualian

assembly adalah null.

Contoh

Contoh kode berikut menunjukkan penggunaan GetAll metode untuk mengidentifikasi sakelar yang digunakan dalam rakitan. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk TraceSource kelas .

SwitchAttribute[] switches = SwitchAttribute.GetAll(typeof(TraceTest).Assembly);
for (int i = 0; i < switches.Length; i++)
{
    Console.WriteLine("Switch name = " + switches[i].SwitchName);
    Console.WriteLine("Switch type = " + switches[i].SwitchType);
}
Dim switches As SwitchAttribute() = SwitchAttribute.GetAll(GetType(TraceTest).Assembly)
Dim i As Integer
For i = 0 To switches.Length - 1
    Console.WriteLine("Switch name = " + switches(i).SwitchName.ToString())
    Console.WriteLine("Switch type = " + switches(i).SwitchType.ToString())
Next i

Berlaku untuk