static void Main(string[] args) { bool showBorder = true; if (showBorder) { _window = new BorderDecorator(new Window()); _textView = new BorderDecorator(new TestView()); } else { _textView = new TestView(); _window = new Window(); } _textView.Draw(); _window.Draw(); Component window = new Window(); window.Draw(); Component windowWithBorder = new BorderDecorator(new Window()); windowWithBorder.Draw(); Component textView = new BorderDecorator(new ColorDecorator(new TestView())); textView.Draw(); }
//Useing decorator we can add new functionality to desired class without changing it static void Main(string[] args) { IComponent comp = new Component(); comp.Draw(); comp = new DerivedDrecorator(comp); comp.Draw(); Console.ReadLine(); }