MethodDataCollection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示集合中可用的方法集。
public ref class MethodDataCollection : System::Collections::ICollection
public class MethodDataCollection : System.Collections.ICollection
type MethodDataCollection = class
interface ICollection
interface IEnumerable
Public Class MethodDataCollection
Implements ICollection
- 继承
-
MethodDataCollection
- 实现
示例
以下示例列出有关 使用类的 Win32_Process.Create 方法 MethodData 的信息。 有关 Win32_Process 类的详细信息,请参阅 Windows Management Instrumentation 文档。
using System;
using System.Management;
public class Sample
{
public static void Main()
{
// Get the WMI class
ManagementClass processClass =
new ManagementClass("Win32_Process");
processClass.Options.UseAmendedQualifiers = true;
// Get the methods in the class
MethodDataCollection methods =
processClass.Methods;
// display the method names
Console.WriteLine("Method Name: ");
foreach (MethodData method in methods)
{
if(method.Name.Equals("Create"))
{
Console.WriteLine(method.Name);
Console.WriteLine("Description: " +
method.Qualifiers["Description"].Value);
Console.WriteLine();
Console.WriteLine("In-parameters: ");
foreach(PropertyData i in
method.InParameters.Properties)
{
Console.WriteLine(i.Name);
}
Console.WriteLine();
Console.WriteLine("Out-parameters: ");
foreach(PropertyData o in
method.OutParameters.Properties)
{
Console.WriteLine(o.Name);
}
Console.WriteLine();
Console.WriteLine("Qualifiers: ");
foreach(QualifierData q in
method.Qualifiers)
{
Console.WriteLine(q.Name);
}
Console.WriteLine();
}
}
}
}
Imports System.Management
Public Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
' Get the WMI class
Dim processClass As ManagementClass = _
New ManagementClass("Win32_Process")
processClass.Options.UseAmendedQualifiers = True
' Get the methods in the class
Dim methods As MethodDataCollection = _
processClass.Methods
' display the method names
Console.WriteLine("Method Name: ")
For Each method As MethodData In methods
If (method.Name.Equals("Create")) Then
Console.WriteLine(method.Name)
Console.WriteLine("Description: " & _
method.Qualifiers("Description").Value)
Console.WriteLine()
Console.WriteLine("In-parameters: ")
For Each i As PropertyData In _
method.InParameters.Properties
Console.WriteLine(i.Name)
Next
Console.WriteLine()
Console.WriteLine("Out-parameters: ")
For Each o As PropertyData In _
method.OutParameters.Properties
Console.WriteLine(o.Name)
Next
Console.WriteLine()
Console.WriteLine("Qualifiers: ")
For Each q As QualifierData In _
method.Qualifiers
Console.WriteLine(q.Name)
Next
Console.WriteLine()
End If
Next
End Function 'Main
End Class
属性
| 名称 | 说明 |
|---|---|
| Count |
获取集合中的 MethodDataCollection 对象数。 |
| IsSynchronized |
获取一个值,该值指示对象是否同步。 |
| Item[String] |
从 .. 中MethodData获取指定的MethodDataCollection值。 |
| SyncRoot |
获取要用于同步的对象。 |
方法
| 名称 | 说明 |
|---|---|
| Add(String, ManagementBaseObject, ManagementBaseObject) |
将一个MethodData添加到MethodDataCollection。 此重载会将具有指定参数对象的新方法添加到集合中。 |
| Add(String) |
将一个MethodData添加到MethodDataCollection。 此重载将添加一个没有参数的新方法。 |
| CopyTo(Array, Int32) |
将复制到 MethodDataCollection 数组中。 |
| CopyTo(MethodData[], Int32) |
MethodDataCollection将复制到专用MethodData数组。 |
| Equals(Object) |
确定指定的对象是否等于当前对象。 (继承自 Object) |
| GetEnumerator() |
返回一个枚举器。MethodDataCollection |
| GetHashCode() |
用作默认哈希函数。 (继承自 Object) |
| GetType() |
获取当前实例的 Type。 (继承自 Object) |
| MemberwiseClone() |
创建当前 Object的浅表副本。 (继承自 Object) |
| Remove(String) | |
| ToString() |
返回一个表示当前对象的字符串。 (继承自 Object) |
显式接口实现
| 名称 | 说明 |
|---|---|
| IEnumerable.GetEnumerator() |
返回循环访问的IEnumerator一个 MethodDataCollection 。 |
扩展方法
| 名称 | 说明 |
|---|---|
| AsParallel(IEnumerable) |
启用查询的并行化。 |
| AsQueryable(IEnumerable) |
将 IEnumerable 转换为 IQueryable。 |
| Cast<TResult>(IEnumerable) |
将 IEnumerable 的元素强制转换为指定类型。 |
| OfType<TResult>(IEnumerable) |
根据指定类型筛选 IEnumerable 的元素。 |