首页 > 代码库 > 链式生产环境装配

链式生产环境装配

链式生产环节装配:

    /// <summary>    /// 数据,它会反复接收工厂里各个环节的加工    /// </summary>    public class DataStream    {        public string Status { get; set; }    }

 

    /// <summary>    /// 节点抽象类,模拟各种机器    /// </summary>    /// <typeparam name="T"></typeparam>    public abstract class MechineNode<T> : IMechine<T>        where T : DataStream, new()    {        public IMechine<T> Next { get; set; }        public T Data { get; set; }                 public abstract IMechine<T> Execute();                public IMechine<T> Append(IMechine<T> next)         {            this.Next = next;            next.Data = http://www.mamicode.com/this.Data;>

 

    /// <summary>    /// 机器节点1    /// </summary>    /// <typeparam name="T"></typeparam>    public sealed class Mechine1<T> : MechineNode<T>        where T : DataStream, new()    {         public override IMechine<T> Execute()        {            this.Data.Status = "updated by mechine 1";            return this;        }    }

 

    /// <summary>    /// 机器节点2    /// </summary>    /// <typeparam name="T"></typeparam>    public sealed class Mechine2<T> : MechineNode<T>        where T : DataStream, new()    {        public override IMechine<T> Execute()        {            this.Data.Status += ",updated by mechine 2";            return this;        }    }

 

下面是应用:

            DataStream data = http://www.mamicode.com/new DataStream();>