본문 바로가기

C#39

05# Factory Method 패턴2 Creational Patterns static void Main(string[] args) { //BuilderExample(); //FactoryExample(); //FactoryMethodExample(); FactoryMethodExample2(); //Console.WriteLine("Hello World!"); Console.ReadKey(); } static void FactoryMethodExample2() { LogManager logManager = new LogManager(); logManager.AddLog(typeof(Human).Name, new Human()); logManager.AddLog(typeof(Animal).Name, new Animal()); foreach (string key in logMan.. 2019. 5. 23.
04# Factory Method 패턴1 Creational Patterns static void Main(string[] args) { //BuilderExample(); //FactoryExample(); FactoryMethodExample(); //Console.WriteLine("Hello World!"); Console.ReadKey(); } static void FactoryMethodExample() { Document[] documents = new Document[2]; documents[0] = new Resume(); documents[1] = new Report(); foreach(Document document in documents) { Console.WriteLine(string.Format("{0}--", document.GetType().Name).. 2019. 5. 23.
03# 추상 팩토리(Abstract Factory) 패턴 Creational Patterns static void Main(string[] args) { //BuilderExample(); FactoryExample(); //Console.WriteLine("Hello World!"); Console.ReadKey(); } static void FactoryExample() { ContinentFactory africa = new AfricaFactory(); AnimalWorld world = new AnimalWorld(africa); world.RunFoodChain(); ContinentFactory america = new AmericaFactory(); world = new AnimalWorld(america); world.RunFoodChain(); } main.cs using Sy.. 2019. 5. 22.
02# Builder 패턴 Creational Patterns using System; using DesignPatterns.Patterns.Builder; namespace DesignPatterns { class Program { static void Main(string[] args) { BuilderExample(); //Console.WriteLine("Hello World!"); } static void BuilderExample() { //Director 생성, Builder 데이터 입력자. Director director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); //Product 데이터 입력 director.Construct(b1.. 2019. 5. 22.