Click here to Skip to main content
15,891,431 members
Articles / Programming Languages / C#

A Flexible Plugin System

Rate me:
Please Sign up or sign in to vote.
4.98/5 (25 votes)
3 Sep 2008LGPL34 min read 131.3K   1.8K   163  
A generic plugin system used to load and manage plugins
using System;
using System.Collections.Generic;
using System.Text;

namespace Fadd.Plugins
{
    /// <summary>
    /// Arguments for <see cref="ApplicationRequestedHandler{T}"/>
    /// </summary>
    /// <typeparam name="T">Plugin type</typeparam>
    public class ApplicationRequestedEventArgs<T> where T : class, IPlugin
    {
        private IApplication _application;
        private T _plugin;

        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationRequestedEventArgs&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="plugin">Plugin being started.</param>
        public ApplicationRequestedEventArgs(T plugin)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Plugin being started
        /// </summary>
        public T Plugin
        {
            get { return _plugin; }
        }

        /// <summary>
        /// Application that the plugin should be started with.
        /// </summary>
        public IApplication Application
        {
            get { return _application; }
            set { _application = value; }
        }
    }

    /// <summary>
    /// A plugin is about to be started and it needs a <see cref="IApplication"/> interface to be passed to it.
    /// </summary>
    /// <typeparam name="T">A type that implements <see cref="IPlugin"/>.</typeparam>
    /// <param name="source"><see cref="PluginManager{T}"/></param>
    /// <param name="args">Arguments.</param>
    public delegate void ApplicationRequestedHandler<T>(object source, ApplicationRequestedEventArgs<T> args) where T : class, IPlugin;
}

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 GNU Lesser General Public License (LGPLv3)


Written By
Founder 1TCompany AB
Sweden Sweden

Comments and Discussions