Class ExtensionsRepository
Implements an extensions repository which stores singleton instances of the extensions
Inheritance
Namespace: Sdl.Core.PluginFramework.Integration
Assembly: Sdl.Core.PluginFramework.dll
Syntax
public sealed class ExtensionsRepository : Object
Properties
Instance
Single instance of the ExtensionsRepository
Declaration
public static ExtensionsRepository Instance { get; }
Property Value
Type | Description |
---|---|
ExtensionsRepository |
Methods
AddExtension<TResult>(IExtension, ExtensionArguments, Func<IExtension, Object, ExtensionArguments, Object>)
Add an extension to the repository
Declaration
public TResult AddExtension<TResult>(IExtension extension, ExtensionArguments arguments, Func<IExtension, object, ExtensionArguments, object> instanceCreator)
where TResult : class
Parameters
Type | Name | Description |
---|---|---|
IExtension | extension | The extension object |
ExtensionArguments | arguments | The arguments required by the instance creator for the extension instance initialization |
System.Func<IExtension, System.Object, ExtensionArguments, System.Object> | instanceCreator | A delegate passed to initialize a custom extension instance which will get the extension object, default extension instance and the extension initializer arguments |
Returns
Type | Description |
---|---|
TResult | The instance created and stored in the repository or an assignable instance already present in the repository. |
Type Parameters
Name | Description |
---|---|
TResult | The instance which is stored or was created while storing. |
FirstOrDefault(Func<ExtensionStoreItem, Boolean>)
Returns the first element stored in the repository that satisfies a condition or a default value if no such element found.
Declaration
public ExtensionStoreItem FirstOrDefault(Func<ExtensionStoreItem, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Func<ExtensionStoreItem, System.Boolean> | predicate | The predicate used for the searching inside the repository. |
Returns
Type | Description |
---|---|
ExtensionStoreItem | Returns the first element stored in the repository that contains the instance reference. |
FirstOrDefault(Object)
Returns the first element stored in the repository that contains the extension instance reference.
Declaration
public ExtensionStoreItem FirstOrDefault(object extensionInstanceReference)
Parameters
Type | Name | Description |
---|---|---|
System.Object | extensionInstanceReference | The extension instance reference which is searched in the repository |
Returns
Type | Description |
---|---|
ExtensionStoreItem | Returns the first element stored in the repository that contains the instance reference. |
GetAssignableInstanceOrDefault<TResult>(IExtension)
Returns an extension instance from the repository which can be assigned to a specified TResult type or null if none was found.
Declaration
public TResult GetAssignableInstanceOrDefault<TResult>(IExtension extension)
where TResult : class
Parameters
Type | Name | Description |
---|---|---|
IExtension | extension | The extension instance for which the search is done. |
Returns
Type | Description |
---|---|
TResult | Returns the extension instance assignable to TResult. |
Type Parameters
Name | Description |
---|---|
TResult | The assignable instance type which is required from the extension store. |
GetAssignableInstanceOrDefault<TResult>(Type, Type)
Returns an extension instance from the repository which can be assigned to a specified TResult type or null if none was found.
Declaration
public TResult GetAssignableInstanceOrDefault<TResult>(Type extensionAttributeType, Type extensionType)
where TResult : class
Parameters
Type | Name | Description |
---|---|---|
System.Type | extensionAttributeType | The type for an attribute decorating the extension for which the search is done. |
System.Type | extensionType | The extension type for which the search is done. |
Returns
Type | Description |
---|---|
TResult | Returns the extension instance assignable to TResult. |
Type Parameters
Name | Description |
---|---|
TResult | The assignable instance type which is required from the extension store. |
GetAssignableInstanceOrDefault<TAttribute, TExtensionType, TResult>()
Returns an extension instance from the repository which can be assigned to a specified TResult type or null if none was found
Declaration
public TResult GetAssignableInstanceOrDefault<TAttribute, TExtensionType, TResult>()
where TAttribute : ExtensionAttribute where TResult : class
Returns
Type | Description |
---|---|
TResult | Returns the extension instance assignable to TResult. |
Type Parameters
Name | Description |
---|---|
TAttribute | The extension attribute type for which the search is done. |
TExtensionType | The extension type for which the search is done. |
TResult | The assignable instance type which is required from the extension store. |