Modifica

Condividi tramite


ManagementClass.GetRelationshipClasses Method

Definition

Retrieves relationship classes that relate the class to others.

Overloads

GetRelationshipClasses()

Retrieves relationship classes that relate the class to others.

GetRelationshipClasses(ManagementOperationObserver)

Retrieves relationship classes that relate the class to others, asynchronously.

GetRelationshipClasses(String)

Retrieves relationship classes that relate the class to others, where the endpoint class is the specified class.

GetRelationshipClasses(ManagementOperationObserver, String)

Retrieves relationship classes that relate the class to the specified WMI class, asynchronously.

GetRelationshipClasses(String, String, String, EnumerationOptions)

Retrieves relationship classes that relate this class to others, according to specified options.

GetRelationshipClasses(ManagementOperationObserver, String, String, String, EnumerationOptions)

Retrieves relationship classes that relate the class according to the specified options, asynchronously.

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

GetRelationshipClasses()

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves relationship classes that relate the class to others.

public:
 System::Management::ManagementObjectCollection ^ GetRelationshipClasses();
public System.Management.ManagementObjectCollection GetRelationshipClasses ();
member this.GetRelationshipClasses : unit -> System.Management.ManagementObjectCollection
Public Function GetRelationshipClasses () As ManagementObjectCollection

Returns

A collection of association classes that relate the class to any other class.

Examples

The following example uses the GetRelationshipClasses method to list the relationship classes to the CIM_LogicalDisk class. For more information, see CIM_LogicalDisk.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {
        ManagementClass c =
            new ManagementClass("CIM_LogicalDisk");

        foreach (ManagementClass r in c.GetSubclasses())
        {
            Console.WriteLine(
                "Instances of {0} are sub-classes",
                r["__CLASS"]);
        }

        foreach (ManagementClass r in c.GetRelationshipClasses())
        {
            Console.WriteLine(
                "{0} is a relationship class to " +
                c.ClassPath.ClassName,
                r["__CLASS"]);

            foreach (ManagementClass related in c.GetRelatedClasses(
                null, r.ClassPath.ClassName,
                "Association", null, null, null, null))
            {
                Console.WriteLine(
                    "{0} is related to " + c.ClassPath.ClassName,
                    related.ClassPath.ClassName);
            }
        }

        return;
    }
}
Imports System.Management


Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        Dim c As ManagementClass
        c = New ManagementClass("CIM_LogicalDisk")

        For Each r As ManagementClass In c.GetSubclasses()

            Console.WriteLine( _
                "Instances of {0} are sub-classes", _
                r("__CLASS"))
        Next

        For Each r As ManagementClass In c.GetRelationshipClasses()

            Console.WriteLine( _
                "{0} is a relationship class to " & _
                c.ClassPath.ClassName, _
                r("__CLASS"))

            For Each related As ManagementClass In c.GetRelatedClasses( _
                Nothing, r.ClassPath.ClassName, "Association", Nothing, _
                Nothing, Nothing, Nothing)

                Console.WriteLine( _
                    "{0} is related to " & c.ClassPath.ClassName, _
                    related.ClassPath.ClassName)
            Next
        Next


    End Function
End Class

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to

GetRelationshipClasses(ManagementOperationObserver)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves relationship classes that relate the class to others, asynchronously.

public:
 void GetRelationshipClasses(System::Management::ManagementOperationObserver ^ watcher);
public void GetRelationshipClasses (System.Management.ManagementOperationObserver watcher);
member this.GetRelationshipClasses : System.Management.ManagementOperationObserver -> unit
Public Sub GetRelationshipClasses (watcher As ManagementOperationObserver)

Parameters

watcher
ManagementOperationObserver

The object to handle the asynchronous operation's progress.

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to

GetRelationshipClasses(String)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves relationship classes that relate the class to others, where the endpoint class is the specified class.

public:
 System::Management::ManagementObjectCollection ^ GetRelationshipClasses(System::String ^ relationshipClass);
public System.Management.ManagementObjectCollection GetRelationshipClasses (string relationshipClass);
member this.GetRelationshipClasses : string -> System.Management.ManagementObjectCollection
Public Function GetRelationshipClasses (relationshipClass As String) As ManagementObjectCollection

Parameters

relationshipClass
String

The endpoint class for all relationship classes returned.

Returns

A collection of association classes that relate the class to the specified class. For more information about relationship classes, ASSOCIATORS OF Statement.

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to

GetRelationshipClasses(ManagementOperationObserver, String)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves relationship classes that relate the class to the specified WMI class, asynchronously.

public:
 void GetRelationshipClasses(System::Management::ManagementOperationObserver ^ watcher, System::String ^ relationshipClass);
public void GetRelationshipClasses (System.Management.ManagementOperationObserver watcher, string relationshipClass);
member this.GetRelationshipClasses : System.Management.ManagementOperationObserver * string -> unit
Public Sub GetRelationshipClasses (watcher As ManagementOperationObserver, relationshipClass As String)

Parameters

watcher
ManagementOperationObserver

The object to handle the asynchronous operation's progress.

relationshipClass
String

The WMI class to which all returned relationships should point.

Remarks

For more information about relationship classes, see ASSOCIATORS OF Statement.

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to

GetRelationshipClasses(String, String, String, EnumerationOptions)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves relationship classes that relate this class to others, according to specified options.

public:
 System::Management::ManagementObjectCollection ^ GetRelationshipClasses(System::String ^ relationshipClass, System::String ^ relationshipQualifier, System::String ^ thisRole, System::Management::EnumerationOptions ^ options);
public System.Management.ManagementObjectCollection GetRelationshipClasses (string relationshipClass, string relationshipQualifier, string thisRole, System.Management.EnumerationOptions options);
member this.GetRelationshipClasses : string * string * string * System.Management.EnumerationOptions -> System.Management.ManagementObjectCollection
Public Function GetRelationshipClasses (relationshipClass As String, relationshipQualifier As String, thisRole As String, options As EnumerationOptions) As ManagementObjectCollection

Parameters

relationshipClass
String

All resulting relationship classes must derive from this class.

relationshipQualifier
String

Resulting relationship classes must have this qualifier.

thisRole
String

The source class must have this role in the resulting relationship classes.

options
EnumerationOptions

Specifies options for retrieving the results.

Returns

A collection of association classes that relate this class to others, according to the specified options. For more information about relationship classes, ASSOCIATORS OF Statement.

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to

GetRelationshipClasses(ManagementOperationObserver, String, String, String, EnumerationOptions)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves relationship classes that relate the class according to the specified options, asynchronously.

public:
 void GetRelationshipClasses(System::Management::ManagementOperationObserver ^ watcher, System::String ^ relationshipClass, System::String ^ relationshipQualifier, System::String ^ thisRole, System::Management::EnumerationOptions ^ options);
public void GetRelationshipClasses (System.Management.ManagementOperationObserver watcher, string relationshipClass, string relationshipQualifier, string thisRole, System.Management.EnumerationOptions options);
member this.GetRelationshipClasses : System.Management.ManagementOperationObserver * string * string * string * System.Management.EnumerationOptions -> unit
Public Sub GetRelationshipClasses (watcher As ManagementOperationObserver, relationshipClass As String, relationshipQualifier As String, thisRole As String, options As EnumerationOptions)

Parameters

watcher
ManagementOperationObserver

The handler for progress and results of the asynchronous operation.

relationshipClass
String

The class from which all resulting relationship classes must derive.

relationshipQualifier
String

The qualifier which the resulting relationship classes must have.

thisRole
String

The role which the source class must have in the resulting relationship classes.

options
EnumerationOptions

The options for retrieving the results.

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to