static void Main(string[] args)
        {
            var documents         = new List <Manuscript>();
            var standardFormatter = new StandardFormatter();
            var reverseFormatter  = new ReverseFormatter();
            var fancyFormatter    = new FancyFormatter();

            var faq = new FAQ(standardFormatter);

            faq.Title = "The Bridge Pattern FAQ";
            faq.Questions.Add("What is it?", "A design pattern.");
            faq.Questions.Add("When do we use it?", "When you need to separate an abstraction from an implementation.");
            documents.Add(faq);

            var book = new Book(fancyFormatter)
            {
                Title  = "Lots of patterns",
                Author = "John Sonmez",
                Text   = "Blah Blah Blah..."
            };

            documents.Add(book);
            var paper = new TermPaper(reverseFormatter)
            {
                Class      = "Design Patterns",
                Student    = "Joe N00b",
                Text       = "Blah Blah Blah...",
                References = "GOF"
            };

            documents.Add(paper);

            documents.ForEach(m => m.Print());
            ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            List <Manuscript> documents = new List <Manuscript>();

            var standFormatter = new StandardFormatter();
            var faq            = new FAQ(standFormatter);

            faq.Title = "The Bridge Pattern FAq";
            faq.Questions.Add("What is it?", "A design pattern");
            faq.Questions.Add("When do we use it?", "When you need to seperate an abstraction from an implementation");
            documents.Add(faq);


            var backwardsFormatter = new BackwardsFormatter();
            var book = new Book(backwardsFormatter)
            {
                Title  = "Design Patterns",
                Author = "Adrian Gurnett",
                Text   = "Blah blah blah"
            };

            documents.Add(book);


            var fancyFormatter = new FancyFormatter();
            var paper          = new TermPaper(fancyFormatter)
            {
                Class      = "Design Patterns",
                Student    = "Joe N00b",
                Text       = "Blah blah blah",
                References = "GOF"
            };

            documents.Add(paper);


            foreach (var document in documents)
            {
                document.Print();
            }


            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            var documents = new List <Manuscript>();

            // use different formatter
            var formatter = new StandardFormatter();
            //var formatter = new BackwardsFormatter();
            //var formatter = new FancyFormatter();

            var faq = new Faq(formatter);

            faq.Title = "The Bridge Pattern FAQ";
            faq.Questions.Add("What is it?", "A design pattern");
            faq.Questions.Add("When do we use it?", "When you need to separate an abstraction from an implementation.");
            documents.Add(faq);

            var book = new Book(formatter)
            {
                Title  = "Lots of Patterns",
                Author = "John Sonmez",
                Text   = "Blah blah blah..."
            };

            documents.Add(book);

            var paper = new TermPaper(formatter)
            {
                Class      = "Design Patterns",
                Student    = "Joe N00b",
                Text       = "Blah blah blah...",
                References = "GOF"
            };

            documents.Add(paper);

            foreach (var doc in documents)
            {
                doc.Print();
            }

            Console.ReadKey();
        }
예제 #4
0
        static void Main()
        {
            List <Document>  documents = new List <Document>();
            IFormatterBridge formatter = new StandardFormatter();

            var book = new Book(formatter)
            {
                Author = "Dan Brown",
                Title  = "The Da Vinci Code",
                Text   = "Blah blah blah ..."
            };

            documents.Add(book);

            var paper = new TermPaper(formatter)
            {
                Class      = "Software Engineering",
                Student    = "Jeremy Hall, Clara Knight",
                References = "SWE101",
                Text       = "Blah blah blah ..."
            };

            documents.Add(paper);

            var faq = new FAQ(formatter)
            {
                Title = "Design Patterns"
            };

            faq.Questions.Add("Who owns this?", "No one");
            faq.Questions.Add("Who created this?", "No one");
            documents.Add(faq);

            foreach (var document in documents)
            {
                document.Print();
            }

            Console.ReadLine();
        }
예제 #5
0
        static void Main(string[] args)
        {
            List <Docuent> documents         = new List <Docuent>();
            IFormatter     standardFormatter = new ReverseFormatter();
            var            faq = new FAQ(standardFormatter)
            {
                Title = "The Bridge Pattern FAQ",
            };

            faq.Question.Add("What is it?", "A design pattern");
            faq.Question.Add("When to use", "When we want to seprate abstarction from implementaion");

            var book = new Book(standardFormatter)
            {
                Author = "abc",
                Title  = "abc",
                Text   = "blah blah blah"
            };

            var paper = new TermPaper(standardFormatter)
            {
                Class      = "Nursery",
                References = "No reference",
                Student    = "I am the student",
                Text       = "Bridge pattern"
            };

            documents.Add(faq);
            documents.Add(book);
            documents.Add(paper);

            foreach (var document in documents)
            {
                document.Display();
                Console.WriteLine();
            }
            Console.ReadLine();
        }
예제 #6
0
        public void Run()
        {
            List <Manuscript> documents = new List <Manuscript>();

            var faq = new FAQ(new StandardFormatter())
            {
                Title = "Lots of Patterns"
            };

            faq.Questions.Add("Question 1", "Is it a Bridge pattern?");
            faq.Questions.Add("Question 2", "What time is it?");

            documents.Add(faq);

            var book = new Book(new ReverseFormatter())
            {
                Title  = "Title",
                Author = "MySelf",
                Text   = "Some text"
            };

            documents.Add(book);

            var paper = new TermPaper(new FancyFormmater())
            {
                Class      = "New Class",
                References = "References",
                Student    = "A Student",
                Text       = "Some text"
            };

            documents.Add(paper);

            foreach (var doc in documents)
            {
                doc.Print();
            }
        }