static void Main(string[] args) { //桥接模式 Abstraction straction = new RefinedAbstraction(); straction.SetImplementor(new ConcreteImplementorA()); straction.Operation(); straction.SetImplementor(new ConcreteImplementorB()); straction.Operation(); Console.WriteLine("----------------------------------------"); HandsetBrand hb; hb = new HandsetBrandN(); hb.SetHandsetSoft(new Handsetgame()); hb.Run(); hb.SetHandsetSoft(new HandsetAddressList()); hb.Run(); hb = new HandsetBrandM(); hb.SetHandsetSoft(new Handsetgame()); hb.Run(); hb.SetHandsetSoft(new HandsetAddressList()); hb.Run(); Console.Read(); }
private void Start( ) { Abstraction ab = new RefinedAbstraction(); ab.Implementor = new ConcreteImplementorA(); ab.Operation(); }
static void Main(string[] args) { Abstraction ra = new RefinedAbstraction(); ra.Operation(); Console.ReadKey(); }
static void Main() { Abstraction abstraction = new RefinedAbstraction { Implementor = new ConcreteImplementorA() }; abstraction.Operation(); }
static void Main() { var abstraction = new RefinedAbstraction(new ImplementorA()); abstraction.Operation(); abstraction = new RefinedAbstraction(new ImplementorB()); abstraction.Operation(); }
static void Main(string[] args) { RefinedAbstraction ra = new RefinedAbstraction(); ra.Impl = new ConcreteImplementorA(); ra.Opeartion(); ra.Impl = new ConcreteImplementorB(); ra.Opeartion(); }
static void Main(string[] args) { Abstraction ab = new RefinedAbstraction(); ab.Implementor = new ConcreteImplementorA(); ab.Operation(); ab.Implementor = new ConcreteImplementorB(); ab.Operation(); Console.ReadKey(); }
static void Main(string[] args) { Abstraction abstraction; abstraction = new RefinedAbstraction(new ConcreteImp1()); abstraction.Operation(); abstraction = new RefinedAbstraction(new ConcreteImp2()); abstraction.Operation(); }
static void Main(string[] args) { Abstraction ab = new RefinedAbstraction(); ab.Implementor = new ConcreteImplementorFirst(); ab.Operation(); ab.Implementor = new ConcreteImplementorSecond(); ab.Operation(); }
static void Main(string[] args) { Abstraction abstraction = new RefinedAbstraction(); abstraction.Implementor = new ConcreteImplementorA(); abstraction.Operation(); abstraction.Implementor = new ConcreteImplementorB(); abstraction.Operation(); Console.Read(); }
static void Main() { Abstraction ab = new RefinedAbstraction(); // Set implementation and call ab.Implementor = new ConcreteImplementorA(); ab.Operation(); // Change implemention and call ab.Implementor = new ConcreteImplementorB(); ab.Operation(); }
static void Main(string[] args) { Abstraction ab = new RefinedAbstraction(); // Set implementation and call ab.Implementor = new ConcreteImplementorA(); ab.Operation(); // Change implemention and call ab.Implementor = new ConcreteImplementorB(); ab.Operation(); // Wait for user Console.ReadKey(); }
static void Main() { Abstraction abstraction; abstraction = new RefinedAbstraction(3); Console.WriteLine(abstraction.Implementor.GetType()); abstraction = new RefinedAbstraction(30); Console.WriteLine(abstraction.Implementor.GetType()); // Delay. Console.ReadKey(); }
static void Main() { Implementor implementor; Abstraction abstraction; implementor = new ConcreteImplementorA(); abstraction = new RefinedAbstraction(implementor); abstraction.Operation(); implementor = new ConcreteImplementorB(); abstraction = new RefinedAbstraction(implementor); abstraction.Operation(); }
private static void Main() { var abstraction = new RefinedAbstraction { Implementor = new ConcreteImplementorA() }; abstraction.Operation(); abstraction.Implementor = new ConcreteImplementorB(); abstraction.Operation(); Console.ReadKey(); }
static void Main() { Abstraction ab = new RefinedAbstraction(); // Set implementation and call ab.Implementor = new ConcreteImplementorA(); ab.Operation(); // Change implementation and call ab.Implementor = new ConcreteImplementorB(); ab.Operation(); // Wait for user Console.Read(); }
static void Main(string[] args) { Abstraction library = new RefinedAbstraction(); library.Implementor = new ConcreteImplementorCPU(); library.Operation(); library.Implementor = new ConcreteImplementorVideoCard(); library.Operation(); library.Implementor = new ConcreteImplementorHardDisc(); library.Operation(); Console.Read(); }
/// <summary> /// The test bridge. /// </summary> private static void TestBridge() { Abstraction ab = new RefinedAbstraction(); // Set implementation and call ab.Implementor = new ConcreteImplementorA(); ab.Operation(); // Change implemention and call ab.Implementor = new ConcreteImplementorB(); ab.Operation(); // Wait for user Console.ReadKey(); }
public static void Run() { Console.WriteLine("This structural code demonstrates the Bridge pattern which separates (decouples) the interface from its implementation. The implementation can evolve without changing clients which use the abstraction of the object."); Abstraction ab = new RefinedAbstraction(); ab.Implementor = new ConcreteImplementorA(); ab.Operation(); ab.Implementor = new ConcreteImplementorB(); ab.Operation(); /* * ConcreteImplementorA Operation * ConcreteImplementorB Operation */ }
private static void Main(string[] args) { // live example Window window = new XWindow(); window.Draw(); window = new IosWindow(); window.Draw(); Console.WriteLine(); // canonical example var abstraction = new RefinedAbstraction(); abstraction.Implementor = new ConcreateImplementorA(); abstraction.Operation(); abstraction.Implementor = new ConcreateImplementorB(); abstraction.Operation(); }
static void Main(string[] args) { #region 结构实现 Abstraction abstraction = new RefinedAbstraction(); abstraction.Implementor = new ConcreteImplementorA(); abstraction.Operation(); abstraction.Implementor = new ConcreteImplementorB(); abstraction.Operation(); #endregion Console.WriteLine("******************************"); #region 实践应用 MakeCoffeeSingleton whiteCoffeeSingleton = new MakeCoffeeSingleton(new WhiteCoffee()); // 中杯牛奶咖啡 MediumCupCoffee mediumWhiteCoffee = new MediumCupCoffee(); mediumWhiteCoffee.Make(); // 大杯牛奶咖啡 LargeCupCoffee largeCupWhiteCoffee = new LargeCupCoffee(); largeCupWhiteCoffee.Make(); MakeCoffeeSingleton blackCoffeeSingleton = new MakeCoffeeSingleton(new BlackCoffee()); // 中杯原味咖啡 MediumCupCoffee mediumBlackCoffee = new MediumCupCoffee(); mediumBlackCoffee.Make(); // 大杯牛奶咖啡 LargeCupCoffee largeCupBlackCoffee = new LargeCupCoffee(); largeCupBlackCoffee.Make(); #endregion Console.ReadKey(); }