SwitchAttribute.GetAll(Assembly) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回指定程序集的所有开关属性。
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
要检查开关属性的程序集。
返回
一个数组,其中包含程序集的所有 switch 属性。
- 属性
例外
assembly 是 null。
示例
下面的代码示例演示如何使用 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