Class Plugin
Represents a plugin
Implements
Namespace: Artemis.Core
Assembly: Artemis.Core.dll
Syntax
public class Plugin : CorePropertyChanged, IDisposable
Properties
Assembly
The assembly the plugin code lives in
Declaration
public Assembly? Assembly { get; }
Property Value
Type | Description |
---|---|
Assembly |
Bootstrapper
Gets the plugin bootstrapper
Declaration
public PluginBootstrapper? Bootstrapper { get; }
Property Value
Type | Description |
---|---|
PluginBootstrapper |
ConfigurationDialog
Gets or sets a configuration dialog for this plugin that is accessible in the UI under Settings > Plugins
Declaration
public IPluginConfigurationDialog? ConfigurationDialog { get; set; }
Property Value
Type | Description |
---|---|
IPluginConfigurationDialog |
Container
Gets the IOC container of the plugin, only use this for advanced IOC operations, otherwise see Resolve(Type, params object?[]) and Resolve<T>(params object?[])
Declaration
public IContainer? Container { get; }
Property Value
Type | Description |
---|---|
IContainer |
Directory
The plugins root directory
Declaration
public DirectoryInfo Directory { get; }
Property Value
Type | Description |
---|---|
DirectoryInfo |
Features
Gets a read-only collection of all features this plugin provides
Declaration
public ReadOnlyCollection<PluginFeatureInfo> Features { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<PluginFeatureInfo> |
Guid
Gets the plugin GUID
Declaration
public Guid Guid { get; }
Property Value
Type | Description |
---|---|
Guid |
Info
Gets the plugin info related to this plugin
Declaration
public PluginInfo Info { get; }
Property Value
Type | Description |
---|---|
PluginInfo |
IsEnabled
Indicates whether the user enabled the plugin or not
Declaration
public bool IsEnabled { get; }
Property Value
Type | Description |
---|---|
bool |
Profilers
Gets a read-only collection of profiles running on the plugin
Declaration
public ReadOnlyCollection<Profiler> Profilers { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<Profiler> |
Methods
Dispose()
Declaration
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the object and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
GetFeatureInfo<T>()
Looks up the feature info the feature of type T
Declaration
public PluginFeatureInfo GetFeatureInfo<T>() where T : PluginFeature
Returns
Type | Description |
---|---|
PluginFeatureInfo | Feature info of the feature |
Type Parameters
Name | Description |
---|---|
T | The type of feature to find |
GetFeature<T>()
Looks up the instance of the feature of type T
Declaration
public T? GetFeature<T>() where T : PluginFeature
Returns
Type | Description |
---|---|
T | If found, the instance of the feature |
Type Parameters
Name | Description |
---|---|
T | The type of feature to find |
GetProfiler(string)
Gets a profiler with the provided name
, if it does not yet exist it will be created.
Declaration
public Profiler GetProfiler(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the profiler |
Returns
Type | Description |
---|---|
Profiler | A new or existing profiler with the provided |
OnDisabled()
Invokes the Disabled event
Declaration
protected virtual void OnDisabled()
OnEnabled()
Invokes the Enabled event
Declaration
protected virtual void OnEnabled()
OnFeatureAdded(PluginFeatureInfoEventArgs)
Invokes the FeatureAdded event
Declaration
protected virtual void OnFeatureAdded(PluginFeatureInfoEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PluginFeatureInfoEventArgs | e |
OnFeatureRemoved(PluginFeatureInfoEventArgs)
Invokes the FeatureRemoved event
Declaration
protected virtual void OnFeatureRemoved(PluginFeatureInfoEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PluginFeatureInfoEventArgs | e |
Register<TImplementation>(PluginServiceScope)
Registers implementation type TImplementation
with itself as service type.
Declaration
public void Register<TImplementation>(PluginServiceScope scope = PluginServiceScope.Singleton)
Parameters
Type | Name | Description |
---|---|---|
PluginServiceScope | scope | The scope in which the service should live, if you are not sure leave it on singleton. |
Type Parameters
Name | Description |
---|---|
TImplementation | The implementation of the service to register. |
Register<TService, TImplementation>(PluginServiceScope)
Registers service of TService
type implemented by TImplementation
type.
Declaration
public void Register<TService, TImplementation>(PluginServiceScope scope = PluginServiceScope.Singleton) where TImplementation : TService
Parameters
Type | Name | Description |
---|---|---|
PluginServiceScope | scope | The scope in which the service should live, if you are not sure leave it on singleton. |
Type Parameters
Name | Description |
---|---|
TService | The service to register. |
TImplementation | The implementation of the service to register. |
RemoveProfiler(Profiler)
Removes a profiler from the plugin
Declaration
public void RemoveProfiler(Profiler profiler)
Parameters
Type | Name | Description |
---|---|---|
Profiler | profiler | The profiler to remove |
Resolve(Type, params object?[])
Gets an instance of the specified service using the plugins dependency injection container.
Declaration
public object Resolve(Type type, params object?[] arguments)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type of service to resolve. |
object[] | arguments | Arguments to supply to the service. |
Returns
Type | Description |
---|---|
object | An instance of the service. |
See Also
ResolveRelativePath(string?)
Resolves the relative path provided in the path
parameter to an absolute path
Declaration
public string? ResolveRelativePath(string? path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The path to resolve |
Returns
Type | Description |
---|---|
string | An absolute path pointing to the provided relative path |
Resolve<T>(params object?[])
Gets an instance of the specified service using the plugins dependency injection container.
Declaration
public T Resolve<T>(params object?[] arguments)
Parameters
Type | Name | Description |
---|---|---|
object[] | arguments | Arguments to supply to the service. |
Returns
Type | Description |
---|---|
T | An instance of the service. |
Type Parameters
Name | Description |
---|---|
T | The service to resolve. |
See Also
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
Events
Disabled
Occurs when the plugin is disabled
Declaration
public event EventHandler? Disabled
Event Type
Type | Description |
---|---|
EventHandler |
Enabled
Occurs when the plugin is enabled
Declaration
public event EventHandler? Enabled
Event Type
Type | Description |
---|---|
EventHandler |
FeatureAdded
Occurs when an feature is loaded and added to the plugin
Declaration
public event EventHandler<PluginFeatureInfoEventArgs>? FeatureAdded
Event Type
Type | Description |
---|---|
EventHandler<PluginFeatureInfoEventArgs> |
FeatureRemoved
Occurs when an feature is disabled and removed from the plugin
Declaration
public event EventHandler<PluginFeatureInfoEventArgs>? FeatureRemoved
Event Type
Type | Description |
---|---|
EventHandler<PluginFeatureInfoEventArgs> |