コード例 #1
0
        public IActionResult Build(string type)
        {
            var builder = (IComputerBuilder)null;

            switch (type)
            {
            case "home":
                builder = new HomeComputerBuilder();
                break;

            case "office":
                builder = new OfficeComputerBuilder();
                break;

            case "development":
                builder = new DevelopmentComputerBuilder();
                break;

            default:
                break;
            }
            var assembler = new ComputerAssembler(builder);
            var computer  = assembler.AssembleComputer();

            return(View("Success", computer));
        }
コード例 #2
0
        public ActionResult Builder(string userType)
        {
            IComputerBuilder computerBuilder = null;

            switch (userType)
            {
            case "Home":
                computerBuilder = new HomeComputerBuilder();
                break;

            case "Office":
                computerBuilder = new OfficeComputerBuilder();
                break;
            }

            ComputerAssembler a = new ComputerAssembler(computerBuilder);
            Computer          c = a.AssembleComputer();

            return(View());
        }
コード例 #3
0
        public IActionResult Build(string usagetype)
        {
            IComputerBuilder builder = null;

            switch (usagetype)
            {
            case "home":
                builder = new HomeComputerBuilder();
                break;

            case "office":
                builder = new OfficeComputerBuilder();
                break;

            case "development":
                builder = new DevelopmentComputerBuilder();
                break;
            }
            ComputerAssembler assembler = new ComputerAssembler(builder);
            Computer          computer  = assembler.AssembleComputer();

            return(View("Success", computer));
        }