示例#1
0
 public void Build(IComputerBuilder builder)
 {
     builder.SetupProcessor();
     builder.SetupMemory();
     builder.SetupStorage();
     builder.SetupStorage();
 }
        static void Main(string[] args)
        {
            Console.Title        = "Builder Pattern: Computers";
            Console.WindowHeight = (int)(Console.LargestWindowHeight * 0.75);
            Console.BufferHeight = 5000;

            // Create a Falcon Northwest Mach 5 Computer
            Console.WriteLine(
                "\n Create a Falcon Northwest Mach 5 Computer.\n");

            ComputerManufacturer manufacturer  = new ComputerManufacturer();
            IComputerBuilder     falconBuilder = null;

            falconBuilder = new FalconNorthwest_Mach5();
            manufacturer.Construct(falconBuilder);

            Console.WriteLine("{0}", falconBuilder.Computer.ToString());

            // *** Build your own custom-built computer. ***
            Console.WriteLine(
                "\n Create your own custom-built computer.\n");

            // *** Add code here ***
            IComputerBuilder phoenixBuilder = new PhoenixDown_v3();

            manufacturer.Construct(phoenixBuilder);

            Console.WriteLine("{0}", phoenixBuilder.Computer.ToString());

            Console.ReadKey();
        }
示例#3
0
 public void Construct(IComputerBuilder computerBuilder)
 {
     computerBuilder.BuildScreenSize();
     computerBuilder.BuildScreenTouch();
     computerBuilder.BuildOperatingSystem();
     computerBuilder.BuildMemory();
 }
示例#4
0
        static void BuildConsoleWriteLines(string computerType, IComputerBuilder builder)
        {
            ComputerDirector director = new ComputerDirector(builder);
            Computer         computer = director.construct();

            Console.WriteLine($"{computerType}: Os={builder.Os} Graphics Card={builder.GraphicsCard} Cpu={builder.Cpu} Ram={builder.Ram} Storage={builder.Storage}");
        }
示例#5
0
 /// <summary>
 /// 指南(一定要按顺序组)
 /// </summary>
 /// <param name="computerBuilder"></param>
 public Computer Guide(IComputerBuilder computerBuilder)
 {
     ///这里指导 必须按这个顺序组装,且只能每个方法调用一次,防止外部随意调用
     ///当然后来发展的建造者模式就没有这一步了
     return(computerBuilder.UseCpu()
            .UseMemory()
            .UseGraphics().Build());
 }
 public void Construct(IComputerBuilder computerBuilder)
 {
     computerBuilder.BuildCase();
     computerBuilder.BuildMotherboard();
     computerBuilder.BuildVideoCard();
     computerBuilder.BuildSoundCard();
     computerBuilder.BuildPowerSupply();
     computerBuilder.BuildCPU();
     computerBuilder.BuildRAM();
     computerBuilder.BuildHardDrive();
     computerBuilder.BuildOpticalDrive();
     computerBuilder.BuildCoolingDevice();
     computerBuilder.BuildCables();
     computerBuilder.BuildMonitor();
     computerBuilder.BuildKeyboard();
     computerBuilder.BuildMouse();
     computerBuilder.BuildOS();
     computerBuilder.BuildOffice();
 }
示例#7
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());
        }
示例#8
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));
        }
示例#9
0
 public Director(IComputerBuilder builder)
 {
     _builder = builder;
 }
 public SuperComputerBuildDirector(IComputerBuilder builder)
 {
     _builder = builder;
 }
 public ComputerAssembler(IComputerBuilder pComputerBuilder)
 {
     this.computerBuilder = pComputerBuilder;
 }
示例#12
0
 public Computer BuildComputer(IComputerBuilder b)
 {
     b.BuildComputer();
     b.BuildOS();
     return(b.GetProduct());
 }
示例#13
0
 public LaptopBuildDirector(IComputerBuilder builder)
 {
     _builder = builder;
 }
示例#14
0
 public ComputerAssembler(IComputerBuilder computerBuilder)
 {
     _ComputerBuilder = computerBuilder;
 }
示例#15
0
 public ComputerDirector(IComputerBuilder builder)
 {
     this._builder = builder;
 }
 /// <summary>
 /// 构造函数 依赖注入的方式。
 /// 选择 特定的 ConcreteBuilder(具体建造者)
 /// </summary>
 /// <param name="icb"></param>
 public ComputerDiector(IComputerBuilder icb)
 {
     this.computerBuilder = icb;
 }
示例#17
0
 public Director(IComputerBuilder dell)
 {
     _dell = dell;
 }
 public ComputerAssembler(IComputerBuilder builder)
 {
     this.builder = builder;
 }
 /// <summary>
 /// Builds a computer based on a ComputerBuilder
 /// </summary>
 /// <param name="builder">The type of ComputerBuilder to build this computer off of</param>
 public static void Construct(IComputerBuilder builder)
 {
     builder.BuildMotherboard();
     builder.BuildHardDrive();
     builder.BuildCase();
 }
 /// <summary>
 /// Constructs a computer using a builder
 /// </summary>
 /// <param name="builder">The builder</param>
 /// <returns>The constructed computer</returns>
 public Computer Construct(IComputerBuilder builder)
 {
     return(builder.Build());
 }
示例#21
0
 public ComputerCreator(IComputerBuilder builder)
 {
     objBuilder = builder;
 }
示例#22
0
 public SystemDirector(IComputerBuilder builder)
 {
     Builder = builder;
 }
 /// <summary>
 /// 构造函数 依赖注入的方式。
 /// 选择 特定的 ConcreteBuilder(具体建造者)
 /// </summary>
 /// <param name="icb"></param>
 public ComputerDiector(IComputerBuilder icb)
 {
     this.computerBuilder = icb;
 }