Gorgon
Show / Hide Table of Contents

Class GorgonPlugIn

The base for all plug ins used by the IGorgonPlugInService.

Inheritance
object
GorgonPlugIn
EditorPlugIn
GorgonImageCodecPlugIn
GorgonAnimationCodecPlugIn
GorgonFileSystemWriter
GorgonSpriteCodecPlugIn
GorgonFileSystemProvider
GorgonGamingDeviceDriver
Implements
IGorgonNamedObject
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
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 Source

GorgonPlugIn(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 Source

Assembly

Property to return the assembly that contains this plugin.

Declaration
public AssemblyName Assembly { get; }
Property Value
Type Description
AssemblyName
| Edit this page View Source

Description

Property to return the description of the plugin.

Declaration
public string Description { get; }
Property Value
Type Description
string
| Edit this page View Source

Name

Property to return the name of this object.

Declaration
public string Name { get; }
Property Value
Type Description
string
| Edit this page View Source

PlugInPath

Property to return the path to the plugin assembly.

Declaration
public string PlugInPath { get; }
Property Value
Type Description
string

Implements

IGorgonNamedObject

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author