Click here to Skip to main content
15,881,841 members
Articles / Security

A simple plug-in engine using Reflection

Rate me:
Please Sign up or sign in to vote.
4.91/5 (22 votes)
26 Sep 2012CPOL11 min read 66K   1.1K   95  
This article describes how to create and use configurable plug-ins in your application.
using System;
using System.Linq;
using System.Collections.Generic;

namespace PluginBase
{
    /// <summary>
    /// Base class for a plugin
    /// </summary>
    public abstract class PluginBase : MarshalByRefObject
    {
        /// <summary>
        /// Plugin's name
        /// </summary>
        public virtual string Name { get; protected set; }

        /// <summary>
        /// Plugin's description
        /// </summary>
        public virtual string Description { get; protected set; }

        /// <summary>
        /// Plugin's configuration
        /// </summary>
        public virtual ConfigurationBase Configuration { get; set; }

        /// <summary>
        /// Default constructor
        /// </summary>
        public PluginBase()
        {
            Name = "Unnamed plugin";
            Description = "No description";
        }

        /// <summary>
        /// Does some work
        /// </summary>
        public abstract void Run();
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions