Class ExtensionAttribute
Base class extension attributes, defining extension points.
Inheritance
Inherited Members
Namespace: SdlSdl.CorePluginFramework
Assembly: Sdl.Core.PluginFramework.dll
Syntax
[AttributeUsage(AttributeTargets.Class)]
public class ExtensionAttribute : Attribute
Remarks
To define a new extension point, create a new attribute class, extending ExtensionAttribute. The class must be annotated with the ExtensionPointInfoAttribute attribute, which indicates that the class defines an extension point.
Users can now create new extension classes annotated with the new extension attribute, and implementing a specified interface.
To get access to all the extensions registered with your extension point, use GetExtensionPoint<T>(), specifying the type of your extension attribute. For more information, see IExtensionPoint.
When the plug-in manifest is generated, instances of the extension attribute are saved in the plug-in manifest using XML serialization. For that reason, make sure your extension attribute supports this (e.g. add a default constructor).
The framework also provides support for getting property values from the PluginResources.resx resource file, which is deployed together with the plug-in manifest. To specify that the value of a certain string property needs to be retrieved from the resource file, annotate the property definition with the PluginResourceAttribute attribute. Users should now specify the name of the resource key, instead of the actual value, as the property value. When no resource string with the specified key can be found, the framework keeps the specified string as the property value. To define non-string properties whose value is stored in the PluginResources.resx resource file, create a string property, which value should be set to a resource key. When consuming the extension, use GetPluginResource<T>(string) tio retriece the resource from the plug-in resource file.
Constructors
ExtensionAttribute()
Default constructor for XML serialization.
Declaration
public ExtensionAttribute()
ExtensionAttribute(string, string, string)
Constructor with required attributes.
Declaration
public ExtensionAttribute(string id, string name, string description)
Parameters
Type | Name | Description |
---|---|---|
string | id | The unique id for the extension. |
string | name | The name for the extension. Should typically be a key of a resource string in PluginResources.resx. |
string | description | The description for the extension. Should typically be a key of a resource string in PluginResources.resx. |
Properties
Description
Gets or sets the description of the extension.
Declaration
[PluginResource]
public string Description { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
Should typically be a key of a resource string in PluginResources.resx.
Icon
Gets or sets the resource key for an the icon representing this extension. Can be null.
Declaration
public string Icon { get; set; }
Property Value
Type | Description |
---|---|
string |
Id
Gets or sets the unique id of the extension.
Declaration
public string Id { get; set; }
Property Value
Type | Description |
---|---|
string |
Name
Gets or sets the name of the extension.
Declaration
[PluginResource]
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
Should typically be a key of a resource string in PluginResources.resx.
Methods
Validate(IExtensionAttributeInfo, IExtensionValidationContext)
Validates an extension targeting this extension point. This method is called by the framework while generating the plug-in manifest.
Declaration
public virtual void Validate(IExtensionAttributeInfo info, IExtensionValidationContext context)
Parameters
Type | Name | Description |
---|---|---|
IExtensionAttributeInfo | info | Information about the extension. |
IExtensionValidationContext | context | Provides functionality to validate extensions targeting the extension point and report warning or error messages |
ValidateId(IExtensionAttributeInfo, IExtensionValidationContext)
Validates the extension Id. Checks whether this is not null or empty.
Declaration
protected virtual void ValidateId(IExtensionAttributeInfo info, IExtensionValidationContext context)
Parameters
Type | Name | Description |
---|---|---|
IExtensionAttributeInfo | info | Information about the extension. |
IExtensionValidationContext | context | Provides functionality to validate extensions targeting the extension point and report warning or error messages |
ValidateName(IExtensionAttributeInfo, IExtensionValidationContext)
Validates the extension Name. Checks whether this is not null or empty.
Declaration
protected virtual void ValidateName(IExtensionAttributeInfo info, IExtensionValidationContext context)
Parameters
Type | Name | Description |
---|---|---|
IExtensionAttributeInfo | info | Information about the extension. |
IExtensionValidationContext | context | Provides functionality to validate extensions targeting the extension point and report warning or error messages |