/// <summary> /// Método Principal Main para Console /// </summary> private static void Main() { Console.WriteLine("Pattern Observer"); ObserverPattern.Observer01(); Console.WriteLine("\n\n-----------------"); Console.WriteLine("Pattern Singleton"); SingletonPattern.Singleton01(); Console.WriteLine("\n\n-----------------"); Console.WriteLine("Pattern Prototype"); PrototypePattern.CreateCars(); Console.WriteLine("\n\n-----------------"); Console.WriteLine("Build Design Pattern"); BuilderDesignPattern.BuilderDesign01(); Console.WriteLine("\n\n-----------------"); Console.WriteLine("Factory Pattern"); FactoryPattern.FactoryPattern01(); Console.WriteLine("\n\n-----------------"); Console.WriteLine("Abstract Factory Pattern"); AbstractFactoryPattern.AbstractFactory01(); Console.WriteLine("\n\n-----------------"); Console.ReadKey(); }
static void Main(string[] args) { // 模板模式测试 //TemplatePattern templatePattern = new TemplatePattern(); //templatePattern.Main(); // 简单的深拷贝和浅拷贝 //Student student1 = new Student { Id = 10, Name = "aedjoi", Addres = "adjgj", Number = 24 }; //Student student2 = student1; //Student student3 = new Student { Id = student1.Id, Name = student1.Name, Addres = student1.Addres, Number = student1.Number }; //student1.Number = 56; //student1.Name = "安东尼"; //Console.WriteLine($"student1.Number:{student1.Number},Name:{student1.Name}"); //Console.WriteLine($"student2.Number:{student2.Number},Name:{student2.Name}"); //Console.WriteLine($"student3.Number:{student3.Number},Name:{student3.Name}"); // 迪米特法则 //DemeterRule demeterRule = new DemeterRule(); //demeterRule.ClickButtonClose(); // 建造者模式 //BuilderPattern builderPattern = new BuilderPattern(); // 观察者模式 //ObserverPattern observer = new ObserverPattern(); //observer.StartObserver(); // 抽象工厂模式 AbstractFactoryPattern abstractFactory = new AbstractFactoryPattern(); abstractFactory.Main(); Console.ReadLine(); }
static void Main(string[] args) { ////Singleton Pattern Demo //Singleton instance = Singleton.getInstance(); //instance.print(); //Console.Read(); //Factory Pattern Demo PrinterFactoryPattern fp = new PrinterFactoryPattern(); Console.WriteLine("Please enter either Color or bw to print"); string input = Console.ReadLine(); PrinterorScanner output = fp.printInput(input); output.printorscan(); Console.Read(); //Abstract Factory Pattern Demo AbstractFactoryPattern afp = new AbstractFactoryPattern(); Console.WriteLine("Please enter either Scan or Print"); string input1 = Console.ReadLine(); Console.WriteLine("Please enter either Color or bw"); string input2 = Console.ReadLine(); afp.printorscan(input1, input2); Console.Read(); }