SwitchAttribute.GetAll(Assembly) 方法

定義

回傳指定組件的所有開關屬性。

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()

參數

assembly
Assembly

用來檢查開關屬性的組裝。

傳回

一個包含組裝所有開關屬性的陣列。

屬性

例外狀況

assemblynull

範例

以下程式碼範例展示了使用此 GetAll 方法識別組件中所用開關的做法。 此程式碼範例是本類別更大範例 TraceSource 的一部分。

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

適用於