Пример #1
0
        internal static void Main(string[] args)
        {
            var documents = new List<Manuscript>();
            var formatter = new FancyFormatter();

            var faq = new FAQ(formatter) { 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();
            }

            // Wait for user
            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            List<Manuscript> documents = new List<Manuscript>();
            IFormatter standard = new FancyFormatter();
            var faq = new Faq(standard);
            documents.Add(faq);

            var book = new Book(standard);
            book.Title = "Book 1";
            documents.Add(book);

            var paper = new TermPaper(standard);
            documents.Add(paper);

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