Esempio n. 1
0
        public void OrderWorkflow()
        {
            //实例化订货工作流
            //构造指导者
            var director = new PurchaseDirector();
            //构建制造者
            var handelBuilder = new ApplyBuilder();
            //指导者指导构造者构造责任链
            director.Construction(handelBuilder);
            //获取构造责任链
            var handel = handelBuilder.GetHanders();
            var context = new ApplyContext() { States = ApplyStates.Apply };
            //责任链开始执行订购工作流
            for (var i = 0; i < 4; i++)
            {

                handel.ProcessHandel(context);
                switch (context.States)
                {
                    case ApplyStates.Apply:
                    //  context.States = ApplyStates.Approve; break;
                    //case ApplyStates.Approve:
                    //  context.States = ApplyStates.CompleteData; break;
                    case ApplyStates.CompleteData:
                        context.States = ApplyStates.SubmitDeposit; break;
                }
            }

            Assert.AreEqual(context.States, ApplyStates.SubmitDeposit);
        }
Esempio n. 2
0
 public override void ProcessHandel(ApplyContext orderContext)
 {
     Console.WriteLine("拒绝 handeler B 正在处理");
     if (Haneler != null)
     {
         Haneler.ProcessHandel(orderContext);
     }
 }
Esempio n. 3
0
 public override void ProcessHandel(ApplyContext applyContext)
 {
     if (applyContext.States == ApplyStates.Apply)
     {
         Console.WriteLine("同意申请");
         return;
     }
     Haneler.ProcessHandel(applyContext);
 }
Esempio n. 4
0
 public override void ProcessHandel(ApplyContext applyContext)
 {
     if (applyContext.States == ApplyStates.SubmitDeposit)
     {
         Console.WriteLine("保证金已经提交");
     }
     if (Haneler != null)
     {
         Haneler.ProcessHandel(applyContext);
     }
 }
Esempio n. 5
0
 public void ProcessHandel(ApplyContext orderContext)
 {
     //构造指导者
     var director = new RefundDirector();
     //构建制造者
     var handelBuilder = new ApplyBuilder();
     //指导者指导构造者构造责任链
     director.Construction(handelBuilder);
     //获取构造责任链
     var handel = handelBuilder.GetHanders();
     //责任链开始执行订购工作流
        // orderContext.State = new PurchaseState();
     handel.ProcessHandel(new ApplyContext());
 }
Esempio n. 6
0
 ///  <summary>
 /// 处理当前链的逻辑 
 ///  </summary>
 public abstract void ProcessHandel(ApplyContext applyContext);