Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit</strong></p> <p>I completely rewrote my answer based on your question edit. </p> <p>Let me show you just how easy it is to implement a plugin architecture with just the minimal steps.</p> <p><strong>Step 1: Define an interface that your plugins will implement.</strong></p> <pre><code>namespace PluginInterface { public interface IPlugin { string Name { get; } string Run(string input); } } </code></pre> <p><strong>Step 2: Create a plugin that implements IPlugin.</strong></p> <pre><code>namespace PluginX { using PluginInterface; public class Plugin : IPlugin { public string Name { get { return "Plugin X"; } } public string Run(string input) { return input; } } } </code></pre> <p><strong>Step 3: Run the plugin.</strong></p> <pre><code>namespace PluginTest { using System; using System.IO; using System.Runtime.Remoting; using PluginInterface; class Program { static void Main( string[] args ) { string pluginFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PluginX.dll"); ObjectHandle handle = Activator.CreateInstanceFrom(pluginFile, "PluginX.Plugin"); IPlugin plugin = handle.Unwrap() as IPlugin; string pluginName = plugin.Name; string pluginResult = plugin.Run("test string"); } } } </code></pre> <p>Keep in mind, this is just the basic, most straightforward example of a plugin architechure. You can also do things such as</p> <ul> <li>create a plugin host to run your plugin inside of it's own <code>AppDomain</code></li> <li>choose either interfaces, abstract classes, or attributes to decorate your plugins with</li> <li>use reflection, interfaces, IL-emitted thunks or delegates to get the late binding job done</li> </ul> <p>if your design so dictates.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload