Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start");

            // Creational Patterns
            FactoryMethod.Run();
            AbstractFactory.Run();
            Prototype.Run();
            Builder.Run();
            Singleton.Run();

            // Behavioral Patterns
            Strategy.Run();
            Observer.Run();
            Command.Run();
            TemplateMethod.Run();
            Iterator.Run();
            State.Run();
            //ChainOfResponsibility.Run();
            //Interpreter.Run();
            MediatorExample.Run();
            Memento.Run();
            Visitor.Run();

            // Structural
            Decorator.Run();
            Adapter.Run();
            Facade.Run();
            Composite.Run();
            Bridge.Run();
            Flyweight.Run();

            Console.WriteLine("\r\nFinish");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //GenerativePatterns
            FactoryMethod.Run();
            AbstractFactory.Run();
            Singleton.Run();
            LazySingleton.Run();
            Prototype.Run();
            Builder.Run();

            //BehaviorPatterns
            Strategy.Run();
            Observer.Run();
            Command.Run();
            TemplateMethod.Run();
            Iterator.Run();
            State.Run();
            ChainOfResponsibility.Run();
            Interpreter.Run();
            Mediator.Run();
            Memento.Run();
            Visitor.Run();

            //StructuralPatterns
            Decorator.Run();
            Adapter.Run();
            Facade.Run();
            Composite.Run();
            Proxy.Run();
            Bridge.Run();
            Flyweight.Run();

            Console.ReadKey();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Log.Info("== Creational Patterns ==");
            AbstractFactory.Run();
            FactoryMethod.Run();
            Singleton.Run();
            Builder.Run();

            Log.Info("== Structural Patterns ==");


            Log.Info("== Behavioral Patterns ==");
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            // 1 : SINGLETON    (A : SINGLETON WITH THREAD SAFE , B : EAGER LOADING , LAZY LOADING)
            // 2 : FACTORY      (A : SIMPLE FACTORY, B : FACTORY METHOD)

MainLoop:
            Console.WriteLine(NewLine);
            Console.WriteLine("SELECT THE DESIGN PATTERN .FOR E.G. (1/2/3) : ");
            strKeyMain = Console.ReadLine().ToString();
            Console.WriteLine(NewLine);

            if (Convert.ToInt32(strKeyMain) == 1) //SINGLETONPATTERN
            {
ChildLoop1:
                Console.WriteLine("SELECT SINGLETON PATTERN TYPE. FOR E.G. (A/B/C)");
                strKeyChild = Console.ReadLine().ToString();
                if (strKeyChild.ToUpper() == "A")
                {
                    Console.WriteLine("SINGLETON WITH THREAD SAFE");
                    Parallel.Invoke(() => GetSingletonInstance_1(), () => GetSingletonInstance_2());
                }
                else if (strKeyChild.ToUpper() == "B")
                {
                    Console.WriteLine("SINGLETON WITH EAGER LOADING");
                    Parallel.Invoke(() => GetEagerSingletonInstance_1(), () => GetEagerSingletonInstance_2());
                }
                else if (strKeyChild.ToUpper() == "C")
                {
                    Console.WriteLine("SINGLETON WITH LAZY LOADING");
                    Parallel.Invoke(() => GetLazySingletonInstance_1(), () => GetLazySingletonInstance_2());
                }
                else
                {
                    goto ChildLoop1;
                }
            }
            else if (Convert.ToInt32(strKeyMain) == 2) //SIMPLE FACTORY
            {
                Console.WriteLine("SELECT FACTORY PATTERN TYPE. FOR E.G. (A/B/C)");
                strKeyChild = Console.ReadLine().ToString();

ChildLoop2:
                if (strKeyChild.ToUpper() == "A")
                {
                    Console.WriteLine("SIMPLE FACTORY PATTERN");
                    Console.WriteLine("SELECT EMPLOYEE TYPE .FOR E.G. (1,2)");
                    strKeyChilds = Console.ReadLine().ToString();
                    SimpleFactory A = new SimpleFactory();
                    A.GetEmployeeData(Convert.ToInt32(strKeyChilds));
                }
                else if (strKeyChild.ToUpper() == "B")
                {
                    Console.WriteLine("FACTORY METHOD PATTERN");
                    Console.WriteLine("SELECT EMPLOYEE TYPE .FOR E.G. (1,2)");
                    strKeyChilds = Console.ReadLine().ToString();
                    Employee emp = new Employee();
                    emp.EmployeeTypeId = Convert.ToInt32(strKeyChilds);
                    FactoryMethod a = new FactoryMethod();
                    a.GetEmployeeMethodData(emp);
                }
                else if (strKeyChild.ToUpper() == "C")
                {
                    Console.WriteLine("ABSTRACT FACTORYPATTERN");
                    Console.WriteLine("SELECT EMPLOYEE TYPE .FOR E.G. (1,2)");
                    strKeyChilds = Console.ReadLine().ToString();
                    Console.WriteLine("SELECT EMPLOYEE JOB .FOR E.G. (Manager,Others)");
                    strKeyChilds1 = Console.ReadLine().ToString();
                    Employee emp = new Employee();
                    emp.EmployeeTypeId = Convert.ToInt32(strKeyChilds);
                    emp.JobDetails     = Convert.ToString(strKeyChilds1);
                    FactoryMethod a = new FactoryMethod();
                    a.GetEmployeeAbstractFactoryData(emp);
                }
                else
                {
                    goto ChildLoop2;
                }
            }

            Console.WriteLine(NewLine);
            Console.WriteLine("WANT TO CONTINUE (Y/N)?");
            if (Console.ReadLine().ToString().ToUpper() == "Y")
            {
                goto MainLoop;
            }
        }