PropertyDataCollection Klass

Definition

Representerar uppsättningen med egenskaper för ett WMI-objekt.

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
Arv
PropertyDataCollection
Implementeringar

Exempel

I följande exempel visas information om klassen Win32_OperatingSystem med hjälp av PropertyData klassen. Mer information om Win32_OperatingSystem finns i dokumentationen 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

Egenskaper

Name Description
Count

Hämtar antalet objekt i PropertyDataCollection.

IsSynchronized

Hämtar ett värde som anger om objektet är synkroniserat.

Item[String]

Hämtar den angivna egenskapen från syntaxen PropertyDataCollection, med hjälp av [] . Den här egenskapen är indexeraren för PropertyDataCollection klassen.

SyncRoot

Hämtar objektet som ska användas för synkronisering.

Metoder

Name Description
Add(String, CimType, Boolean)

Lägger till en ny PropertyData utan tilldelat värde.

Add(String, Object, CimType)

Lägger till en ny PropertyData med det angivna värdet och CIM-typen (Common Information Model).

Add(String, Object)

Lägger till en ny PropertyData med det angivna värdet. Värdet får inte vara null och måste konverteras till en CIM-typ (Common Information Model).

CopyTo(Array, Int32)

Kopierar PropertyDataCollection till en matris.

CopyTo(PropertyData[], Int32)

Kopierar PropertyDataCollection till en specialiserad PropertyData objektmatris.

Equals(Object)

Avgör om det angivna objektet är lika med det aktuella objektet.

(Ärvd från Object)
GetEnumerator()

Returnerar uppräknaren för den här PropertyDataCollection.

GetHashCode()

Fungerar som standard-hash-funktion.

(Ärvd från Object)
GetType()

Hämtar den aktuella instansen Type .

(Ärvd från Object)
MemberwiseClone()

Skapar en ytlig kopia av den aktuella Object.

(Ärvd från Object)
Remove(String)

Tar bort en PropertyData från PropertyDataCollection.

ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)

Explicita gränssnittsimplementeringar

Name Description
IEnumerable.GetEnumerator()

Returnerar en IEnumerator som itererar via PropertyDataCollection.

Tilläggsmetoder

Name Description
AsParallel(IEnumerable)

Möjliggör parallellisering av en fråga.

AsQueryable(IEnumerable)

Konverterar en IEnumerable till en IQueryable.

Cast<TResult>(IEnumerable)

Omvandlar elementen i en IEnumerable till den angivna typen.

OfType<TResult>(IEnumerable)

Filtrerar elementen i en IEnumerable baserat på en angiven typ.

Gäller för