Click here to Skip to main content
15,886,106 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 130.8K   1.8K   163  
A generic plugin system used to load and manage plugins
using System;
using System.Collections.Generic;

namespace Fadd.Commands
{
    /// <summary>
    /// A mapped command have been assigned all subscribers that 
    /// have been mapped to an interface, subclass, or attribute
    /// that the command contains.
    /// </summary>
    internal class MappedCommand
    {
        private readonly List<CommandHandler> _handlers;
        private bool _dirty = false;

        public MappedCommand(List<CommandHandler> handlers)
        {
            if (handlers == null)
                throw new ArgumentNullException("handlers");

            _handlers = handlers;
        }

        /// <summary>
        /// All delegates that will be invoked for this command.
        /// </summary>
        public List<CommandHandler> Handlers
        {
            get { return _handlers; }
        }

        /// <summary>
        /// Dirty means that a new handler have been added since
        /// the command was last invoked.
        /// This means that we need to recheck whether we got all
        /// handlers.
        /// </summary>
        public bool Dirty
        {
            get { return _dirty; }
            set { _dirty = value; }
        }
    }
}

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