Пример #1
0
        static void Main()
        {
            Subject subject = new Subject();

            new HexaObserver(subject);
            new OctalObserver(subject);
            new BinaryObserver(subject);

            Console.WriteLine("First state change: 15"); subject.SetState(15);
            Console.WriteLine("Second state change: 10"); subject.SetState(10);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Subject subject = new Subject();

            new TempObserverInCelcijus(subject);
            new TempObserverInFahrenheit(subject);

            Console.WriteLine("First");
            subject.SetState(10);
            Console.WriteLine("Second");
            subject.SetState(20);
        }
Пример #3
0
        static void Main(string[] args)
        {
            ISubject subject = new Subject();
            var      third   = new Classes.Observer("Third");

            subject.RegisterObserver(new Classes.Observer("First"));
            subject.RegisterObserver(new Classes.Observer("Second"));
            subject.RegisterObserver(third);

            subject.SetState(100, 20, 30);
            subject.RemoveObserver(third);
            subject.SetState(50, 3, 17);

            Console.ReadKey();
        }
Пример #4
0
        public MainWindow()
        {
            InitializeComponent();

            this.Height           = 950;
            this.Width            = 925;
            this.GuiUC.DefineText = "Adapter pattern works as a bridge between two incompatible interfaces.";

            Subject subject = new Subject();
            var     binary  = new BinaryObserver(subject);
            var     octal   = new OctalObserver(subject);

            subject.SetState(15);

            subject.SetState(200);
        }