Esempio n. 1
0
        private static void VisitorPatternDemo()
        {
            VisitorPatternDemo demo = new VisitorPatternDemo();

            demo.Test();
        }
Esempio n. 2
0
        static void Main()
        {
            Trace.Listeners.Add(new TextWriterTraceListener("SoftwareDesignPaternsOutput.log"));
            Trace.AutoFlush = true;
            Trace.Indent();
            Console.WriteLine("Output text file location ==> \n");
            Console.WriteLine("./SoftwareDesignPatterns/DesignPatterns.ConsoleApp/bin/Debug/SoftwareDesignPatternsOutput.log");
            Console.WriteLine("\nAlternatively, see the visual studio output window.");

            #region Writing All Output in Trace File
            Trace.WriteLine("=================== PROGRAM STARTS HERE ===================" + Environment.NewLine);

            Trace.WriteLine("========== FACTORY PATTERN RESULT ===========" + Environment.NewLine);
            FactoryPatternDemo.Output();

            Trace.WriteLine("========== ABSTRACT FACTORY PATTERN RESULT ===========" + Environment.NewLine);
            AbstractFactoryPatternDemo.Output();

            Trace.WriteLine("========== SINGLETON PATTERN RESULT ===========" + Environment.NewLine);
            SingletonPatternDemo.Output();

            Trace.WriteLine("========== BUILDER PATTERN RESULT ===========" + Environment.NewLine);
            BuilderPatternDemo.Output();

            Trace.WriteLine("========== PROTOTYPE PATTERN RESULT ===========" + Environment.NewLine);
            PrototypePatternDemo.Output();

            Trace.WriteLine("========== ADAPTER PATTERN RESULT ===========" + Environment.NewLine);
            AdapterPatternDemo.Output();

            Trace.WriteLine("========== BRIDGE PATTERN RESULT ===========" + Environment.NewLine);
            BridgePatternDemo.Output();

            Trace.WriteLine("========== FILTER PATTERN RESULT ===========" + Environment.NewLine);
            FilterPatternDemo.Output();

            Trace.WriteLine("========== COMPOSITE PATTERN RESULT ===========" + Environment.NewLine);
            CompositePatternDemo.Output();

            Trace.WriteLine("========== DECORATOR PATTERN RESULT ===========" + Environment.NewLine);
            DecoratorPatternDemo.Output();

            Trace.WriteLine("========== FACADE PATTERN RESULT ===========" + Environment.NewLine);
            FacadePatternDemo.Output();

            Trace.WriteLine("========== FLYWEIGHT PATTERN RESULT ===========" + Environment.NewLine);
            FlyweightPatternDemo.Output();

            Trace.WriteLine("========== PROXY PATTERN RESULT ===========" + Environment.NewLine);
            ProxyPatternDemo.Output();

            Trace.WriteLine("========== PROXY PATTERN RESULT ===========" + Environment.NewLine);
            ChainPatternDemo.Output();

            Trace.WriteLine("========== COMMAND PATTERN RESULT ===========" + Environment.NewLine);
            CommandPatternDemo.Output();

            Trace.WriteLine("========== INTERPRETER PATTERN RESULT ===========" + Environment.NewLine);
            InterpreterPatternDemo.Output();

            Trace.WriteLine("========== ITERATOR PATTERN RESULT ===========" + Environment.NewLine);
            IteratorPatternDemo.Output();

            Trace.WriteLine("========== MEDIATOR PATTERN RESULT ===========" + Environment.NewLine);
            MediatorPatternDemo.Output();

            Trace.WriteLine("========== MEMENTO PATTERN RESULT ===========" + Environment.NewLine);
            MementoPatternDemo.Output();

            Trace.WriteLine("========== OBSERVER PATTERN RESULT ===========" + Environment.NewLine);
            ObserverPatternDemo.Output();

            Trace.WriteLine("========== STATE PATTERN RESULT ===========" + Environment.NewLine);
            StatePatternDemo.Output();

            Trace.WriteLine("========== NULL OBJECT PATTERN RESULT ===========" + Environment.NewLine);
            NullPatternDemo.Output();

            Trace.WriteLine("========== STRATEGY PATTERN RESULT ===========" + Environment.NewLine);
            StrategyPatternDemo.Output();

            Trace.WriteLine("========== TEMPLATE PATTERN RESULT ===========" + Environment.NewLine);
            TemplatePatternDemo.Output();

            Trace.WriteLine("========== VISITOR PATTERN RESULT ===========" + Environment.NewLine);
            VisitorPatternDemo.Output();

            Trace.WriteLine("========== MVC PATTERN RESULT ===========" + Environment.NewLine);
            MvcPatternDemo.Output();

            Trace.WriteLine("========== BUSINESS DELEGATE PATTERN RESULT ===========" + Environment.NewLine);
            BusinessDelegatePatternDemo.Output();

            Trace.WriteLine("========== COMPOSITE ENTITY PATTERN RESULT ===========" + Environment.NewLine);
            CompositeEntityPatternDemo.Output();

            Trace.WriteLine("========== DATA ACCESS OBJECT PATTERN RESULT ===========" + Environment.NewLine);
            DaoPatternDemo.Output();

            Trace.WriteLine("========== FRONT CONTROLLER PATTERN RESULT ===========" + Environment.NewLine);
            FrontControllerPatternDemo.Output();

            Trace.WriteLine("========== INTERCEPTING FILTER PATTERN RESULT ===========" + Environment.NewLine);
            InterceptingFilterPatternDemo.Output();

            Trace.WriteLine("========== SERVICE LOCATOR PATTERN RESULT ===========" + Environment.NewLine);
            ServiceLocatorPatternDemo.Output();

            Trace.WriteLine("========== TRANSFER OBJECT PATTERN RESULT ===========" + Environment.NewLine);
            TransferObjectPatternDemo.Output();

            Trace.WriteLine("=================== ROGRAM ENDS HERE ===================");
            #endregion

            Trace.Unindent();
            Trace.Flush();
            Console.ReadKey();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            #region 1.创建者模式
            //工厂模式测试
            Patterns.FactoryPattern.ShapeFactory.Test();
            //抽象工厂模式测试
            FactoryProducer.Test();
            //单例模式测试
            Singleton.Test();
            //建造者模式
            FoodPattern.Test();
            //原型模式
            PrototypeDemo.Test();
            #endregion

            #region 2.结构型模式
            //适配器模式
            AdapterPatternDemo.Test();
            //桥接模式
            BridgePatternDemo.Test();
            //过滤器模式
            FilterPatternDemo.Test();
            //组合模式
            CompositePattern.Test();
            //装饰器模式
            DecoratorPatternDemo.Test();
            //外观模式
            FacadePatternDemo.Test();
            //享元模式
            FlyWeightPatternDemo.Test();
            //代理模式
            ProxyPatternDemo.Test();
            #endregion

            #region 3.行为型模式
            //责任链模式
            ChainPatternDemo.Test();
            //命令模式
            CommandPatternDemo.Test();
            //解释器模式
            InterpreterPatternDemo.Test();
            //迭代器模式
            IteratorPatternDemo.Test();
            //中介者模式
            MediatorPatternDemo.Run();
            //备忘录模式
            MementoPatternDemo.Run();
            //观察者模式
            ObserverPatternDemo.Run();
            //状态模式
            StatePatternDemo.Run();
            //空对象模式
            NullObjectPatternDemo.Run();
            //策略模式
            StrategyPatternDemo.Run();
            //模板模式
            TemplatePatternDemo.Run();
            //访问者模式
            VisitorPatternDemo.Run();
            #endregion

            #region 4.J2EE模式
            //MVC模式
            MVCPatternDemo.Run();
            //业务代表模式
            BusinessDelegatePatternDemo.Run();
            //组合实体模式
            CompositeEntityPatternDemo.Run();
            //数据访问对象模式
            DataAccessObjectPatternDemo.Run();
            //前端控制器模式
            FrontControllerPatternDemo.Run();
            //拦截过滤器模式
            InterceptingFilterPatternDemo.Run();
            //服务定位器模式
            ServiceLocatorPatternDemo.Run();
            //传输对象模式
            TransferObjectPatternDemo.Run();
            #endregion

            Console.ReadLine();
        }