Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("========================================ObserverPatternExample===============================");
            var observerExample = new ObserverExample();

            observerExample.PrintResult();
            Console.WriteLine("*************************End of ObserverPatternExampl************************************");
            Console.WriteLine("========================================ChainOfResponsibilityExample===============================");
            var corExample = new ChainOfResponsibilityExample();

            corExample.PrintResult();
            Console.WriteLine("*************************End of ChainOfResponsibilityExample************************************");
            Console.WriteLine("========================================FacadeExample===============================");
            var facadExample = new FacadePatternExample();

            facadExample.PrintResult();
            Console.WriteLine("*************************End of FacadeExample************************************");
            Console.WriteLine("========================================Decorator Example===============================");
            var decoratorExample = new DecoratorExample();

            decoratorExample.PrintResult();
            Console.WriteLine("*************************End of Decorator Example************************************");
            Console.WriteLine("========================================Bridge Example===============================");
            var bridgeExample = new BridgePatternExample();

            bridgeExample.PrintResult();
            Console.WriteLine("*************************End of Bridge Example************************************");

            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // Behavioural examples
            var strategy = new StrategyExample();

            strategy.RunExample();

            var chain = new ChainOfResponsibilityExample();

            chain.RunExample();

            var memento = new MementoExample();

            memento.RunExample();

            // Creational examples
            var singleton = new SingletonExample();

            singleton.RunExample();

            var builder = new BuilderExample();

            builder.RunExample();

            // Structural examples
            var adapter = new AdapterExample();

            adapter.RunExample();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            AdapterExample testAdapter = new AdapterExample();

            testAdapter.TestAdapter();

            Console.WriteLine("\n**********\n");

            ChainOfResponsibilityExample testChainOfResponsibility = new ChainOfResponsibilityExample();

            testChainOfResponsibility.TestChainOfResponsibility();

            Console.WriteLine("\n**********\n");

            Secretary testCommand = new Secretary();

            testCommand.PrintDocument();

            Console.WriteLine("\n**********\n");

            FacadeExample testFacade = new FacadeExample();

            testFacade.TestFacade();

            Console.WriteLine("\n**********\n");

            Furniture testAbstractFactory = new Furniture();

            testAbstractFactory.TestFurniture();

            Console.WriteLine("\n**********\n");

            FactoryMethodExample testFactoryMethod = new FactoryMethodExample();

            testFactoryMethod.TestFactoryMethod();

            Console.WriteLine("\n**********\n");

            OrderState OrderState = new OrderState();

            OrderState.Register();
            OrderState.Approve();
            OrderState.Dispatch();
        }
Esempio n. 4
0
        public static void Run()
        {
            char key;

            while (true)
            {
                printMenu();

                key = Console.ReadKey().KeyChar;

                Console.WriteLine();
                switch (key)
                {
                case 's':
                    StrategyPatternExample.Display();
                    break;

                case 'o':
                    ObserverPatternExample.Display();
                    break;

                case 'c':
                    CommandPatternExample.Display();
                    break;

                case 'm':
                    CommandPatternMulti.Display();
                    CommandPatternMacro.Display();
                    break;

                case 't':
                    TemplateMethodPatternExample.Display();
                    break;

                case 'i':
                    IteratorPatternExample.Display();
                    break;

                case 'a':
                    NoStatePatternExample.Display();
                    StatePatternExample.Display();
                    break;

                case 'h':
                    ChainOfResponsibilityExample.Display();
                    break;

                case 'n':
                    InterpreterPatternExample.Display();
                    break;

                case 'd':
                    MediatorPatternExample.Display();
                    break;

                case 'e':
                    MementoPatternExample.Display();
                    break;

                case 'v':
                    VisitorPatternExample.Display();
                    break;

                case 'x': return;
                }
                Console.ReadKey();
            }
        }