zoukankan      html  css  js  c++  java
  • Builder生成器模式

    using System;
    using System.Configuration;

    namespace Builder
    {

     public abstract class House
     {
     }
     public abstract class Windows
     {
     }
     public abstract class Wall
     {
     }
     public abstract class Floor
     {
     }
     public abstract class HouseCeiling
     {
     }

     public abstract class Builder
     {
      public abstract void BuilderDoor();
      public abstract void BuildWindows();
      public abstract void BuildWall();
      public abstract void BuildFloor();
      public abstract void BuildHouseCeiling();

      public abstract House GetHouse();
     }
     /// <summary>
     /// ///////////////////////////////////////////////////////
     /// </summary>

     public class RomainHouse:House
     {
     }
     public class RomainWindows:Windows
     {
     }
     public class RomainWall:Wall
     {
     }
     public class RomainFloor:Floor
     {
     }
     public class RomainHouseCeiling:HouseCeiling
     {
     }
     public class RomainBuilder:Builder
     {
      public override void BuilderDoor()
      {
      }
      public override void BuildWindows()
      {
      }
      public override void BuildWall()
      {
      }
      public override void BuildFloor()
      {
      }
      public override void BuildHouseCeiling()
      {
      }

      public override House GetHouse()
      {
       return new RomainHouse();
      }
     }

     /// <summary>
     /// /////////////////////////////////////////////////////////////////////////////////
     /// 不变的主线
     /// </summary>
     public class GameManager
     {
      public static House CreateHouse(Builder builder)
      {
       builder.BuilderDoor();
       builder.BuilderDoor();

       builder.BuildWall();
       builder.BuildWall();

       builder.BuildWindows();
       builder.BuildWindows();

       builder.BuildHouseCeiling();

       builder.BuildFloor();

       return builder.GetHouse();

      }
     }
     public class Test
     {
      /// <summary>
      /// 用到了动态特指
      /// </summary>
      public static void Main()
      {
       House house;
       string builderName,assemblyName;
       assemblyName=System.Configuration.ConfigurationSettings.AppSettings["AssemblyName"];
       builderName=System.Configuration.ConfigurationSettings.AppSettings["BuilderName"];

       System.Reflection.Assembly assembly = System.Reflection.Assembly.Load(assemblyName);
       Type t=assembly.GetType(builderName);

       Builder builder=(Builder)System.Activator.CreateInstance(t);
       house=GameManager.CreateHouse(builder);
      }
     }
    }

  • 相关阅读:
    Linux mii-tool 命令
    MySQL 主从复制
    MySQL 备份与恢复
    SOAP 版本可能不匹配: 出现意外的 Envelope 命名空间 http://schemas.xmlsoap.org/wsdl/
    网管邮件配置
    ORA-10873
    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    安装 ORACLE 11G出现Error Message:PRVF-7535
    mount /dev/sr0 /media/cdrom you must specify the filesystem type
    NBU 还原windows ORACLE数据库(BW)
  • 原文地址:https://www.cnblogs.com/kuailewangzi1212/p/343440.html
Copyright © 2011-2022 走看看