예제 #1
0
        private static void ChainOfResponsibilityPattern()
        {
            #region ProjectDelivery

            Requirment r1 = new Requirment
            {
                Name           = "Projet 1",
                IsDesingNeeded = true
            };

            Requirment r2 = new Requirment
            {
                Name = "Project 2",
                areUIChangesNeeded = true
            };

            IHandler architect    = new Architect();
            IHandler uiDeveloper  = new UIDeveloper();
            IHandler dba          = new DBA();
            IHandler appDeveloper = new AppDeveloper();
            IHandler qa           = new QA();

            architect.SetNextHandler(uiDeveloper);
            uiDeveloper.SetNextHandler(dba);
            dba.SetNextHandler(appDeveloper);
            appDeveloper.SetNextHandler(qa);

            architect.Handle(r1);

            architect.Handle(r2);

            #endregion ProjectDelivery

            #region Leave Aprroval

            ILeaveHandler teamLead       = new TeamLead();
            ILeaveHandler projectManager = new ProjectManager();
            ILeaveHandler hr             = new DeliveryManager();

            teamLead.SetNextHandler(projectManager);
            projectManager.SetNextHandler(hr);

            teamLead.LeaveApproval("Chandra", 8);

            #endregion Leave Aprroval

            #region Logger

            LoggerHandler info    = new Info();
            LoggerHandler warning = new Warning();
            LoggerHandler error   = new Error();

            info.SetNextLoggerHandler(warning);
            warning.SetNextLoggerHandler(error);

            info.Log("Error");

            #endregion Logger
        }