SwitchAttribute.GetAll(Assembly) 方法

定義

傳回指定之組件的所有參數屬性。

public:
 static cli::array <System::Diagnostics::SwitchAttribute ^> ^ GetAll(System::Reflection::Assembly ^ assembly);
public static System.Diagnostics.SwitchAttribute[] GetAll (System.Reflection.Assembly assembly);
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

適用於