Two description models: Custom Attributes and XML Manifests

Every add-in and add-in root has to provide a description of the extensibility elements it provides. There are two ways of doing this:
  • Using custom attributes: Mono.Addins provides several attributes which can be used to mark classes as extensions or extension points. Attributes can also be used to declare add-in information and dependencies.
  • Using an add-in manifest: a manifest is an XML description of an add-in. Attributes are very easy to use, but not all extensibility features that Mono.Addins provides can be expressed using attributes.

It is allowed to use a mix of both approaches to describe an add-in. That is, an add-in could declare simple extensions using attributes, and more complex extensions in a manifest embedded as a resource.

Custom Attributes

Here is a summary of all custom attributes that can be used to describe an extension model. All these attributes belong to the Mono.Addins namespace.

Add-in definition:

Attribute Target Description
AddinAttribute Assembly Declares that an assembly is an add-in
AddinRootAttribute Assembly Declares that an assembly is an add-in host
AddinAuthorAttribute Assembly Author of an add-in
AddinDependencyAttribute Assembly Declares an add-in dependency
AddinLocalizerGettextAttribute Assembly Declares gettext localizer information for the add-in
AddinModuleAttribute Assembly Declares an optional module
ImportAddinAssemblyAttribute Assembly Declares that an assembly belongs to an add-in. Useful when an add-in is composed by several assemblies
ImportAddinFileAttribute Assembly Declares that a file belongs to an add-in. Useful when an add-in is composed by several files


Extension points:

Attribute Target Description
ExtensionPointAttribute Assembly Declares an extension point
TypeExtensionPointAttribute Class Declares a type extension point


Extensions:

Attribute Target Description
ExtensionAttribute Class Declares a new type extension
ExtensionAttributeAttribute Class Declares an attribute value for a type extension (used together with ExtensionAttribute)


Custom extension nodes:

Attribute Target Description
ExtensionNodeAttribute Class Can be applied to an ExtensionNode subclass to specify some node type metadata such as name or description
ExtensionNodeChildAttribute Class Can be applied to an ExtensionNode subclass to specify child node types
NodeAttributeAttribute Several Can be applied to a field, property, parameter or class to bind a member to an extension node attribute

XML Manifest

Any declaration that can be done using custom attributes can also be done in a manifest, but not everything that can be declared in a manifest can also be expressed using custom attributes.

An XML add-in manifest is an XML file which contains extension model definitions. Manifests can be deployed as standalone files, or they can be embedded as a resource in assemblies. Manifest files are identified by their extension, which must be ".addin" or ".addin.xml". When embedded in an assembly, a manifest can be split in several .addin files.

Here is a summary of the elements that can be used to describe an extension model:

Element Description
/Addin Root element for add-in and add-in root descriptions
/Addin/Runtime/Import Declares that an assembly or data file belongs to the add-in
/Addin/Runtime/ScanExclude Declares that a file or directory must be ignored by the add-in scanner
/Addin/Dependencies/Addin Declares an add-in dependency
/Addin/ExtensionPoint Declares an extension point
/Addin/ExtensionPoint/ExtensionNode Describes an extension node of an extension point
/Addin/ExtensionPoint/ConditionType Declares a condition type local to an extension point
/Addin/Extension Declares an extension
/Addin/ExtensionNodeSet Declares an extension node set
/Addin/ConditionType Declares a global condition type
/Addin/Module Declares an optional extension module
/Addin/Localizer Declares a localizer for the add-in

Last edited May 20, 2010 at 11:48 AM by slluis, version 9

Comments

No comments yet.