共用方式為


ModelElementExtensionMethods.TryGetExtension<T> Method (ModelElement)

Get the ExtensionElement of the specified type from the available extensions of this ModelElement. If this element has no such extension then the result will be null.

Namespace:  Microsoft.VisualStudio.Modeling.Extensibility
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.10.0.dll)

Syntax

'宣告
<ExtensionAttribute> _
Public Shared Function TryGetExtension(Of T As ExtensionElement) ( _
    element As ModelElement _
) As T
public static T TryGetExtension<T>(
    this ModelElement element
)
where T : ExtensionElement
[ExtensionAttribute]
public:
generic<typename T>
where T : ExtensionElement
static T TryGetExtension(
    ModelElement^ element
)
static member TryGetExtension : 
        element:ModelElement -> 'T  when 'T : ExtensionElement
JScript does not support generic types or methods.

Type Parameters

  • T
    The type of ExtensionElement to retrieve

Parameters

Return Value

Type: T
The ExtensionElement of the requested type, or null if the element has no such extension

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ModelElement. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

.NET Framework Security

See Also

Reference

ModelElementExtensionMethods Class

TryGetExtension Overload

Microsoft.VisualStudio.Modeling.Extensibility Namespace