Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Decorator Example");
            DecoratorPattern.DecoratorExample();
            Console.WriteLine("Decorator Example Finished");

            Console.WriteLine("----------------------------------------------------------");

            Console.WriteLine("Adapter Example");
            AdapterPattern.AdapterExample();
            Console.WriteLine("Adapter Example Finished");



            Console.WriteLine("Factory Example");
            EmployeeFactory EmployeeFactory = new ConcreteEmployeeFactory();

            IFactory permanentEmployee = EmployeeFactory.Factory("PermanentEmployee");

            permanentEmployee.details();

            IFactory TemporaryEmployee = EmployeeFactory.Factory("TemporaryEmployee");

            TemporaryEmployee.details();
            Console.WriteLine("Factory Example Finished");
            Console.Read();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //NumberVisitor n_visitor = new NumberVisitor();
            //Number1 n = new MyInt();
            //n.Visit(n_visitor);

            //NaturalList nl = new NaturalList();

            /*while (true)
             * {
             *
             *  Option<int> a = nl.GetNext();
             *  Console.WriteLine(a);
             * }
             */

            FactoryPattern fp = new FactoryPattern();

            fp.Run();

            DecoratorPattern dp = new DecoratorPattern();

            dp.Run();


            //MusicLibraryVisitor music_library_visitor = new MusicLibraryVisitor();
            //List<Song> songs = new List<Song>();
            //songs.Add(new HeavyMetal("Hallowed Be Thy Name"));
            //songs.Add(new Jazz("Autumn Leaves"));
            //songs.Add(new HeavyMetal("War Pigs"));
            //foreach (var song in songs) { song.Visit(music_library_visitor); }
            //Console.WriteLine("Amount of heavy metal music: " + music_library_visitor.heavyMetal.Count);
            //Console.WriteLine("Amount of jazz music: " + music_library_visitor.jazz.Count);

            //OPTION VISITOR version 1
            //IOptionVisitor<int, int> opt_visitor = new LambdaIOptionVisitor<int, int>(i => i + 1, () => { throw new Exception("Expecting a value..."); });
            //Option<int> opt = new Some<int>(5);
            //int res = opt.Visit(opt_visitor);
            //Console.WriteLine(res);

            //OPTION VISITOR version 2
            //Option<int> number = new Some<int>(5);
            //int inc_number = number.Visit(() => { throw new Exception("Expecting a value..."); }, i => i + 1);
            //Console.WriteLine(inc_number);
            //number = new None<int>();
            //inc_number = number.Visit(() => { throw new Exception("Expecting a value..."); }, i => i + 1);
            //Console.WriteLine(inc_number);
            Console.ReadLine();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            ChainOfResponsiblity cor = new ChainOfResponsiblity();

            int[] req = { 1, 5, 23, 19, 21, 18 };
            cor.HandleRequestControl(req);

            DecoratorPattern dc = new DecoratorPattern();

            dc.PizzaMaker();

            FlyweightPattern fw = new FlyweightPattern();

            fw.ControlFlyweight();

            //ZFileSystem temp = new ZFileSystem();
            Console.ReadLine();
        }
        public static void Main(string[] args)
        {
            Pattern builderPattern = new BuilderPattern();

            builderPattern.Run();

            Pattern decoratorPattern = new DecoratorPattern();

            decoratorPattern.Run();

            Pattern singletonPattern = new SingletonPattern();

            singletonPattern.Run();

            Pattern commandPattern = new CommandPattern();

            commandPattern.Run();
        }