ManagementEnumeratorAttribute Class

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Defines a static method as the method that is used to return all instances of a class. The method must be a static method, and the return type of the method must be IEnumerable.

Namespace: System.Management
Assembly:   System.Core (in System.Core.dll)

[AttributeUsageAttribute(AttributeTargets.Constructor|AttributeTargets.Method, AllowMultiple = false)]
public sealed class ManagementEnumeratorAttribute : ManagementNewInstanceAttribute
Not applicable.

The following example shows how to use the Enumerator attribute to mark a method that is used to enumerate instances of a class.


// Use the ManagementEnumerator attribute to specify the method
// that is used to enumerate instances of the class.
// This method must be static and must return IEnumerable.
// This method returns an array that contains the current
// class instance.
public static IEnumerable Enumerate()
    if (_instance == null)
        _instance = new ClassName();
    return new ClassName[1] { _instance };

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows Server 2003, Windows XP SP2, Windows Vista

The .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.5