SwitchAttribute.GetAll(Assembly) 方法

定義

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

C#
public static System.Diagnostics.SwitchAttribute[] GetAll (System.Reflection.Assembly assembly);

參數

assembly
Assembly

要在其中檢查參數屬性的組件。

傳回

陣列,包含組件的所有參數屬性。

例外狀況

assemblynull

範例

下列程式代碼範例示範如何使用 GetAll 方法來識別元件中使用的參數。 此程式代碼範例是針對 類別提供的較大範例的 TraceSource 一部分。

C#
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);
}

適用於

產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1