EnumerationOptions.EnumerateDeep 属性

定义

获取或设置一个值,该值指示是否向派生自指定超级类的所有类请求递归枚举。 如果 false返回,则仅返回即时派生类成员。

public:
 property bool EnumerateDeep { bool get(); void set(bool value); };
public bool EnumerateDeep { get; set; }
member this.EnumerateDeep : bool with get, set
Public Property EnumerateDeep As Boolean

属性值

true 如果向派生自指定超级类的所有类请求递归枚举,则为 ;否则,为 false.

示例

以下示例使用EnumerationOptions构造函数初始化变量EnumerationOptions,然后获取 WMI 类及其子类的所有实例。

using System;
using System.Management;
public class RemoteConnect
{
    public static void Main()
    {
        EnumerationOptions opt = new EnumerationOptions();

        // Will enumerate instances of the given class
        // and any subclasses.
        opt.EnumerateDeep = true;
        ManagementClass c = new ManagementClass("CIM_Service");
        foreach (ManagementObject o in c.GetInstances(opt))
            Console.WriteLine(o["Name"]);
    }
}
Imports System.Management
Public Class RemoteConnect

    Public Overloads Shared Function Main( _
    ByVal args() As String) As Integer

        Dim opt As New EnumerationOptions

        ' Will enumerate instances of the given class
        ' and any subclasses.
        opt.EnumerateDeep = True
        Dim mngmtClass As New ManagementClass("CIM_Service")
        Dim o As ManagementObject
        For Each o In mngmtClass.GetInstances(opt)
            Console.WriteLine(o("Name"))
        Next o

        Return 0
    End Function
End Class

注解

属性值

true 如果向派生自指定超级类的所有类请求递归枚举,则为 ;否则,为 false. 默认值为 false

.NET Framework 安全性

直接调用方完全信任。 此成员不能由部分受信任的代码使用。 有关详细信息,请参阅 使用部分受信任的代码的库

适用于