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
- Реализации
Примеры
В следующем примере перечислены сведения о классе Win32_OperatingSystem с помощью PropertyData класса. Дополнительные сведения о Win32_OperatingSystem см. в документации по инструментированию управления Windows.
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, CimType) |
Добавляет новый PropertyData с указанным значением и типом Common Information Model (CIM). |
| Add(String, Object) |
Добавляет новое PropertyData значение с указанным значением. Значение не может иметь значение NULL и должно быть преобразовано в тип Common Information Model (CIM). |
| 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() |
Возвращает значение IEnumerator , которое выполняет итерацию через PropertyDataCollection. |
Методы расширения
| Имя | Описание |
|---|---|
| AsParallel(IEnumerable) |
Включает параллелизацию запроса. |
| AsQueryable(IEnumerable) |
Преобразует IEnumerable в IQueryable. |
| Cast<TResult>(IEnumerable) |
Приведение элементов IEnumerable к указанному типу. |
| OfType<TResult>(IEnumerable) |
Фильтрует элементы IEnumerable на основе указанного типа. |