Class GorgonPlugIn
The base for all plug ins used by the IGorgonPlugInService.
Inheritance
Implements
Inherited Members
Namespace: Gorgon.PlugIns
Assembly: Gorgon.Core.dll
Syntax
public abstract class GorgonPlugIn : IGorgonNamedObject
Remarks
Any plug ins used by the IGorgonPlugInService must be derived from this type. The plug in service will scan any plug in assemblies loaded and will enumerate only types that inherit this type.
Defining your own plugin
While any class can be a plugin within an assembly, Gorgon uses the following strategy to define a plugin assembly.
In your host assembly (an application, DLL, etc...):
// This will go into your host assembly (e.g. an application, another DLL, etc...)
// This defines the functionality that you wish to override in your plugin assembly.
public abstract class FunctionalityBase
{
public abstract int DoSomething();
}
// This too will go into the host assembly and be overridden in your plugin assembly.
public abstract class FunctionalityPlugIn
: GorgonPlugIn
{
public abstract FunctionalityBase GetNewFunctionality();
protected FunctionalityPlugIn(string description)
{
}
}
In your plugin assembly:
tip
Be sure to reference your host assembly in the plugin assembly project.
// We put the namespace here because when loading the plugin in our example below, we need to give a fully qualified name for the type that we're loading.
namespace Fully.Qualified.Name
{
// Typically Gorgon makes the extension classes internal, but they can have a public accessor if you wish.
class ConcreteFunctionality
: FunctionalityBase
{
public override int DoSomething()
{
return 42;
}
}
public class ConcreteFunctionalityPlugIn
: FunctionalityPlugIn
{
public override FunctionalityBase GetNewFunctionality()
{
return new ConcreteFunctionality();
}
public ConcreteFunctionalityPlugIn()
: base("What is the answer to life, the universe, and blah blah blah?")
{
}
}
}
Constructors
| Edit this page View SourceGorgonPlugIn(string)
Initializes a new instance of the GorgonPlugIn class.
Declaration
protected GorgonPlugIn(string description)
Parameters
Type | Name | Description |
---|---|---|
string | description | Optional description of the plugin. |
Remarks
Implementors of this base class should pass in a hard coded description to the base constructor.
Properties
| Edit this page View SourceAssembly
Property to return the assembly that contains this plugin.
Declaration
public AssemblyName Assembly { get; }
Property Value
Type | Description |
---|---|
AssemblyName |
Description
Property to return the description of the plugin.
Declaration
public string Description { get; }
Property Value
Type | Description |
---|---|
string |
Name
Property to return the name of this object.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
PlugInPath
Property to return the path to the plugin assembly.
Declaration
public string PlugInPath { get; }
Property Value
Type | Description |
---|---|
string |