static void Main(string[] args)
        {
            Staff staff = new Staff();

            staff.Name = "小李";

            Manager manager = new Manager();

            manager.Name = "王经理";
            VicePresident vice = new VicePresident();

            vice.Name            = "钱总";
            staff.NextApprover   = manager;
            manager.NextApprover = vice;
            staff.ProcessRequest(new PurchaseHandle(5000, "大力丸"));
            staff.ProcessRequest(new PurchaseHandle(30000, "数控床"));
            staff.ProcessRequest(new PurchaseHandle(700000, "机器手套"));
            Console.ReadKey();
        }
示例#2
0
        void Test()
        {
            PurchaseRequest requestTelphone  = new PurchaseRequest(4000.0, "Telphone");
            PurchaseRequest requestSoftware  = new PurchaseRequest(10000.0, "Visual Studio");
            PurchaseRequest requestComputers = new PurchaseRequest(40000.0, "Computers");

            Approver manager = new Manager("LearningHard");
            Approver Vp      = new VicePresident("Tony");
            Approver Pre     = new President("BossTom");

            // 设置责任链
            manager.NextApprover = Vp;
            Vp.NextApprover      = Pre;

            // 处理请求
            manager.ApproverReuqest(requestTelphone);
            manager.ApproverReuqest(requestSoftware);
            manager.ApproverReuqest(requestComputers);
            Console.ReadLine();
        }