共用方式為


ModelElementExtensionMethods Class

These extension methods allow a DSL to be extended without altering the original definition.

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Modeling.Extensibility.ModelElementExtensionMethods

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

Syntax

'Declaration
<ExtensionAttribute> _
Public NotInheritable Class ModelElementExtensionMethods
public static class ModelElementExtensionMethods
[ExtensionAttribute]
public ref class ModelElementExtensionMethods abstract sealed
[<AbstractClass>]
[<Sealed>]
type ModelElementExtensionMethods =  class end
public final class ModelElementExtensionMethods

The ModelElementExtensionMethods type exposes the following members.

Methods

  Name Description
Public methodStatic member AddExtension(ModelElement, DomainClassInfo) Extend this ModelElement with a newly instantiated extension of the specified domain type. An InvalidOperationException will be thrown if the element already has an extension of that type.
Public methodStatic member AddExtension(ModelElement, ExtensionElement) Extend this ModelElement with a specific extension. An InvalidOperationException will be thrown if the element already has an extension of the same type.
Public methodStatic member AddExtension(ModelElement, Guid) Extend this ModelElement with newly instantiated extension of the identified domain type. An InvalidOperationException will be thrown if the element already has an extension of that type.
Public methodStatic member AddExtension(ModelElement, Type) Extend this ModelElement with a newly instantiated extension of the specified type. An InvalidOperationException will be thrown if the element already has an extension of that type.
Public methodStatic member AddExtension<T>(ModelElement) Extend this ModelElement with a newly instantiated extension of a particular type. An InvalidOperationException will be thrown if the element already has an extension of the same type.
Public methodStatic member GetAllExtensions Return an enumerable that performs a breadth first traversal across the tree of extension elements embedded in this ModelElement.
Public methodStatic member GetBaseElement Returns the root of the virtual MEL in which the specified ModelElement is participating.
Public methodStatic member GetExtension(ModelElement, DomainClassInfo)
Public methodStatic member GetExtension(ModelElement, Guid)
Public methodStatic member GetExtension(ModelElement, Type) Get the ExtensionElement of the specified type from the available extensions of this ModelElement. If the element has no such extension then an InvalidOperationException will be raised.
Public methodStatic member GetExtension<T>(ModelElement) Get the ExtensionElement of the specified type from the available extensions of this ModelElement. If the element has no such extension then an InvalidOperationException will be raised.
Public methodStatic member IsExtendedBy(ModelElement, DomainClassInfo) Query whether this ModelElement is currently extended by an ExtensionElement of a particular type.
Public methodStatic member IsExtendedBy(ModelElement, Guid) Query whether this ModelElement is currently extended by an ExtensionElement of a particular type.
Public methodStatic member IsExtendedBy(ModelElement, Type) Query whether this ModelElement is currently extended by an ExtensionElement of a particular type.
Public methodStatic member RemoveExtension(ModelElement, DomainClassInfo) Remove any extension of the specified ModelElement that is of a particular type.
Public methodStatic member RemoveExtension(ModelElement, ExtensionElement) Remove a specified ExtensionElement from the extensions of this ModelElement.
Public methodStatic member RemoveExtension(ModelElement, Guid) Remove any extension of the specified ModelElement that is of a particular type.
Public methodStatic member RemoveExtension(ModelElement, Type) Remove any extension of this ModelElement that is of a particular type.
Public methodStatic member TryGetExtension(ModelElement, DomainClassInfo)
Public methodStatic member TryGetExtension(ModelElement, Guid)
Public methodStatic member TryGetExtension(ModelElement, Type)
Public methodStatic member TryGetExtension<T>(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.

Top

Remarks

For more information see Adding Extensions to DSL Definitions.

Import the namespace Microsoft.VisualStudio.Modeling.Extensibility to make these operations available as if methods of ModelElement. Otherwise the same operations are available as static methods on ModelElement.

Thread Safety

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

See Also

Reference

Microsoft.VisualStudio.Modeling.Extensibility Namespace