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

适用于