Click here to Skip to main content
15,886,724 members
Articles / Programming Languages / XML

Non-Stopping Upgradable Service Framework

Rate me:
Please Sign up or sign in to vote.
5.00/5 (7 votes)
27 Jan 2012CPOL6 min read 28.6K   283   43  
A framework designed for support upgrade components in service without stop running
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassContract
{
    public class Component : IComponent
    {
        #region IComponent Members

        public IList<IComponent> DownstreamComponents { get; set; }
        public bool IsUpgradable { get; set; }
        public string Name { get; set; }
        public string Downstreams { get; set; }

        public virtual bool Start() { return true; }
        public virtual bool Stop() { return true; }

        public virtual bool DoBusiness(object obj = null)
        {
            Console.WriteLine("[{0}] DoBusiness, obj={1}", this.Name, obj);

            OnAfterBusiness(obj);

            return true;
        }

        protected virtual void OnAfterBusiness(object obj)
        {
            if (this.AfterBusiness != null)
            {
                this.AfterBusiness(this, new ComponentDataEventArgs(obj));
            }
        }

        public virtual event EventHandler<ComponentDataEventArgs> AfterBusiness;

        #endregion
    }
}

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 (Senior)
China China
I started to programming in 2002, started when I was grade 2 in university, I participated some part-time projects at that time, I have much experiences on Windows, includes C#, ASP.NET, Visual Basic, Visual C++, AJAX, Power Shell Script, JavaScript, XML..etc, I am learning design and architect.

Comments and Discussions