Пример #1
0
        static void Main(string[] args)
        {
            var remoteControl = new AdvancedRemoteControl(new SamsungTv());

            remoteControl.TurnOn();
            System.Console.ReadKey();
        }
Пример #2
0
        public static void Run()
        {
            var remoteControl = new AdvancedRemoteControl(new SamsungTV());

            remoteControl.TurnOn();
            remoteControl.SetChannel(12);
        }
Пример #3
0
            public static void Run()
            {
                AdvancedRemoteControl rc = new AdvancedRemoteControl("SONY");

                rc.TurnOn();
                rc.SetChannel(50);
                rc.NextChannel();
                rc.TurnOff();
            }
Пример #4
0
        public static void Structural_Bridge()
        {
            var remoteControl = new RemoteControl(new SonyTV());

            remoteControl.TurnOn();

            // we want to use an advanced remote control
            var advRemoteControl = new AdvancedRemoteControl(new SonyTV());

            advRemoteControl.TurnOn();

            // If we want a new brand, just add a new class that implements the IDevice interface
            var remoteControlSamsung = new RemoteControl(new SamsungTV());

            remoteControlSamsung.TurnOn();

            // This is the Bridge pattern, We don't have to create several new classes and add them to our hierachy
            // We use the Bridge pattern when we have a hierarchy that can grow in two different dimensions
            // We can split a complex hierarchy into two separate hierarchies that can grow independently
            // this makes our application design more extensible and maintainable.
        }