PropertyDataCollection 类

定义

表示 WMI 对象的属性集。

public ref class PropertyDataCollection : System::Collections::ICollection
public class PropertyDataCollection : System.Collections.ICollection
type PropertyDataCollection = class
    interface ICollection
    interface IEnumerable
Public Class PropertyDataCollection
Implements ICollection
继承
PropertyDataCollection
实现

示例

下面的示例使用 类PropertyData列出有关 Win32_OperatingSystem 类的信息。 有关 Win32_OperatingSystem的详细信息,请参阅 Windows Management Instrumentation 文档。

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        ManagementClass osClass =
            new ManagementClass("Win32_OperatingSystem");

        osClass.Options.UseAmendedQualifiers = true;

        // Get the Properties in the class
        PropertyDataCollection properties =
            osClass.Properties;

        // display the Property names
        Console.WriteLine("Property Name: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(
                "---------------------------------------");
            Console.WriteLine(property.Name);
            Console.WriteLine("Description: " +
                property.Qualifiers["Description"].Value);
            Console.WriteLine();

            Console.WriteLine("Type: ");
            Console.WriteLine(property.Type);

            Console.WriteLine();

            Console.WriteLine("Qualifiers: ");
            foreach(QualifierData q in
                property.Qualifiers)
            {
                Console.WriteLine(q.Name);
            }
            Console.WriteLine();

            foreach (ManagementObject c in osClass.GetInstances())
            {
                Console.WriteLine("Value: ");
                Console.WriteLine(
                    c.Properties[property.Name.ToString()].Value);

                Console.WriteLine();
            }
        }
    }
}
Imports System.Management


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

        ' Get the WMI class
        Dim osClass As ManagementClass = _
            New ManagementClass("Win32_OperatingSystem")

        osClass.Options.UseAmendedQualifiers = True

        ' Get the Properties in the class
        Dim properties As PropertyDataCollection = _
            osClass.Properties

        ' display the Property names
        Console.WriteLine("Property Name: ")
        For Each p As PropertyData In properties

            Console.WriteLine( _
                "---------------------------------------")
            Console.WriteLine(p.Name)
            Console.WriteLine("Description: " & _
                p.Qualifiers("Description").Value)
            Console.WriteLine()

            Console.WriteLine("Type: ")
            Console.WriteLine(p.Type)

            Console.WriteLine()

            Console.WriteLine("Qualifiers: ")
            For Each q As QualifierData In _
                p.Qualifiers

                Console.WriteLine(q.Name)
            Next
            Console.WriteLine()

            For Each c As ManagementObject In osClass.GetInstances()

                Console.WriteLine("Value: ")
                Console.WriteLine( _
                    c.Properties(p.Name.ToString()).Value)

                Console.WriteLine()
            Next
        Next

    End Function
End Class

属性

Count

获取 PropertyDataCollection 中的对象的数目。

IsSynchronized

获取一个指示对象是否已同步的值。

Item[String]

使用 [] 语法从 PropertyDataCollection 中获取指定属性。 此属性是 PropertyDataCollection 类的索引器。

SyncRoot

获取要用于同步的对象。

方法

Add(String, CimType, Boolean)

添加新的、没有赋值的 PropertyData

Add(String, Object)

添加新的、带有指定值的 PropertyData。 值不能为 null,并且必须能够转换为公共信息模型 (CIM) 类型。

Add(String, Object, CimType)

添加一个具有指定值和公共信息模型 (CIM) 类型的新 PropertyData

CopyTo(Array, Int32)

PropertyDataCollection 复制到一个数组中。

CopyTo(PropertyData[], Int32)

PropertyDataCollection 复制到一个专用的 PropertyData 对象数组。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

返回此 PropertyDataCollection 的枚举数。

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
Remove(String)

PropertyData 中移除 PropertyDataCollection

ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

IEnumerable.GetEnumerator()

返回循环访问 IEnumeratorPropertyDataCollection

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

适用于