Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing an abstract class as the contract in plugin framework
    primarykey
    data
    text
    <p>Can an abstract class be used as the contract object between a 'Host' and a 'plugin'? The idea is that the plugin inherits the contract (we call it an adapter). We are also understanding that all participants in the framework must inherit <code>MarshalByRefObject</code> (MBRO). So, this is what we were thinking - </p> <p><strong>Host</strong>:</p> <pre><code>class Host : MarshalByRefObject { } </code></pre> <p><strong>Contract</strong>:</p> <pre><code>public abstract class PluginAdapter : MarshalByRefObject { } </code></pre> <p><strong>Plugin</strong>:</p> <pre><code>class myPlugin : PluginAdapter { } </code></pre> <p>All three exist in separate asm's. Our Host will create a new AppDomain for each plugin, and the PluginAdapter is created as follows:</p> <pre><code>{ ObjectHandle instHandle = Activator.CreateInstance( newDomain, data.Assembly.FullName, data.EntryPoint.FullName); PluginAdapter adapter = (PluginAdapter)instHandle.Unwrap(); } </code></pre> <p><strong>EDIT</strong>: where <code>data</code> is the concrete type of <code>myPlugin</code>.</p> <p>We were wondering if this implementation of the framework would work. We have seen articles using an interface (IPlugin) for the plugin derivation, and a concrete class as the contract. Those articles would also say that an abstract class can be used, but no examples of that implementation given. Is it required that the contract be a concrete class?</p> <p><strong>EDIT</strong>: In this example by Richard Blewett - <a href="http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/c89db4d2-8b1a-46e6-9e78-c5cc465340ab" rel="nofollow noreferrer">C# Reflection</a> - he uses a much simpler implementation:</p> <p><strong>Contract</strong>:</p> <pre><code>public interface IPlugIn { // do stuff } </code></pre> <p><strong>Plugin</strong>:</p> <pre><code>public class PlugIn : MarshalByRefObject, IPlugIn { } </code></pre> <p>Now, if using an abstract class as the contract, the Plugin cannot inherit both the contract and MBRO. What, then, becomes the best implementation for a scalable plugin framework. Should we go ahead and implement remoting even though, initially, we are developing for single-machine operation? This project is expected to become distributed across a network, possibly across the Internet as well. We simply have not implemented Tcp yet because we are trying to get the basics of a plugin framework fully understood and operational.</p> <p>Does it make sense to implement Tcp remoting on a single machine using loopback?</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. 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