本文整理汇总了C#中System.Management.ManagementObjectCollection.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementObjectCollection.GetEnumerator方法的具体用法?C# ManagementObjectCollection.GetEnumerator怎么用?C# ManagementObjectCollection.GetEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.ManagementObjectCollection
的用法示例。
在下文中一共展示了ManagementObjectCollection.GetEnumerator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildDataSet
private DataSet BuildDataSet(ManagementObjectCollection entries, Progress progress)
{
// Create the dataset that the datagrid is going to bind to
DataSet ds = new DataSet();
DataTable table = new DataTable("Entries");
table.Columns.Add("EntryType");
table.Columns.Add("TimeWritten", typeof(DateTime));
table.Columns.Add("Category", typeof(ushort));
table.Columns.Add("Source");
table.Columns.Add("EventID", typeof(uint));
table.Columns.Add("Message");
table.Columns.Add("Index", typeof(uint));
ds.Tables.Add(table);
groupNames = new List<String>();
// Enumerate through the events and add each item to the dataset
using (System.Management.ManagementObjectCollection.ManagementObjectEnumerator enumerator = entries.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (progress != null)
{
if (cancelFill)
{
return null;
}
MethodInvoker invoker = new MethodInvoker(progress.IncrementValue);
invoker.BeginInvoke(null, null);
}
ManagementBaseObject entry = enumerator.Current;
if (!groupNames.Contains((string)(entry["SourceName"])))
{
groupNames.Add((string)(entry["SourceName"]));
}
AddTableRow(table, entry);
Application.DoEvents();
}
}
FillSourceItems(groupNames);
return ds;
}
示例2: PopulateNamespaceList
public WmiResult PopulateNamespaceList(ManagementObjectCollection pGatheredNamespaces)
{
Namespaces = new List<string>();
CollectedNamespaces = pGatheredNamespaces;
ManagementObjectCollection.ManagementObjectEnumerator namespaceEnumerator = pGatheredNamespaces.GetEnumerator();
while (namespaceEnumerator.MoveNext())
{
foreach (PropertyData item in namespaceEnumerator.Current.Properties)
{
Namespaces.Add(item.Value.ToString());
}
}
return this;
}