PropertyDataCollection 类

定义

表示 WMI 对象的属性集。Represents the set of properties of a WMI object.

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类的信息。The following example lists information about the Win32_OperatingSystem class using the PropertyData class. 有关Win32_OperatingSystem的详细信息, 请参阅Windows Management Instrumentation文档。For more information about Win32_OperatingSystem, see the Windows Management Instrumentation documentation.

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 中的对象的数目。Gets the number of objects in the PropertyDataCollection.

IsSynchronized

获取一个指示对象是否已同步的值。Gets a value indicating whether the object is synchronized.

Item[String]

使用 [] 语法从 PropertyDataCollection 中获取指定属性。Gets the specified property from the PropertyDataCollection, using [] syntax. 此属性是 PropertyDataCollection 类的索引器。This property is the indexer for the PropertyDataCollection class.

SyncRoot

获取要用于同步的对象。Gets the object to be used for synchronization.

方法

Add(String, CimType, Boolean)

添加新的、没有赋值的 PropertyDataAdds a new PropertyData with no assigned value.

Add(String, Object)

添加新的、带有指定值的 PropertyDataAdds a new PropertyData with the specified value. 值不能为 null,并且必须能够转换为公共信息模型 (CIM) 类型。The value cannot be null and must be convertible to a Common Information Model (CIM) type.

Add(String, Object, CimType)

添加一个具有指定值和公共信息模型 (CIM) 类型的新 PropertyDataAdds a new PropertyData with the specified value and Common Information Model (CIM) type.

CopyTo(Array, Int32)

PropertyDataCollection 复制到一个数组中。Copies the PropertyDataCollection into an array.

CopyTo(PropertyData[], Int32)

PropertyDataCollection 复制到一个专用的 PropertyData 对象数组。Copies the PropertyDataCollection to a specialized PropertyData object array.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetEnumerator()

返回此 PropertyDataCollection 的枚举数。Returns the enumerator for this PropertyDataCollection.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Remove(String)

PropertyData 中移除 PropertyDataCollectionRemoves a PropertyData from the PropertyDataCollection.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

IEnumerable.GetEnumerator()

返回循环访问 IEnumeratorPropertyDataCollectionReturns an IEnumerator that iterates through the PropertyDataCollection.

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于