MethodDataCollection 类

定义

表示在集合中可用的方法集。Represents the set of methods available in the collection.

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
实现

示例

下面的示例使用MethodData类列出有关Win32_Process方法的信息。The following example lists information about the Win32_Process.Create method using the MethodData class. 有关Win32_Process类的详细信息,请参阅Windows Management Instrumentation文档。For more information on the Win32_Process class, see the Windows Management Instrumentation documentation.

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 集合中的对象数。Gets the number of objects in the MethodDataCollection collection.

IsSynchronized

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

Item[String]

MethodData 中获取指定的 MethodDataCollectionGets the specified MethodData from the MethodDataCollection.

SyncRoot

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

方法

Add(String)

MethodData 中添加一个 MethodDataCollectionAdds a MethodData to the MethodDataCollection. 此重载将向集合添加无参数的新方法。This overload will add a new method with no parameters to the collection.

Add(String, ManagementBaseObject, ManagementBaseObject)

MethodData 中添加一个 MethodDataCollectionAdds a MethodData to the MethodDataCollection. 此重载将向集合添加带有指定参数对象的新方法。This overload will add a new method with the specified parameter objects to the collection.

CopyTo(Array, Int32)

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

CopyTo(MethodData[], Int32)

MethodDataCollection 复制到一个专用 MethodData 数组。Copies the MethodDataCollection to a specialized MethodData array.

Equals(Object)

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

(继承自 Object)
GetEnumerator()

返回 MethodDataCollection 的一个枚举数。Returns an enumerator for the MethodDataCollection.

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)

MethodData 中移除 MethodDataCollectionRemoves a MethodData from the MethodDataCollection.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

IEnumerable.GetEnumerator()

返回循环访问 IEnumeratorMethodDataCollectionReturns an IEnumerator that iterates through the MethodDataCollection.

扩展方法

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.

适用于