static void Main() { var component = new ConcreteComponent(); var decorator = new ConcreteDecorator(component); decorator.Operation(); }
static void Main() { ConcreteDecorator decorator = new ConcreteDecorator(); Component component = new ConcreteComponentA(); decorator.Component = component; decorator.Operation(); Console.WriteLine(new string('-', 30)); component = new ConcreteComponentB(); decorator.Component = component; decorator.Operation(); // Delay. Console.ReadKey(); }
static void Main(string[] args) { Component obj = new ConcreteComponent(); obj.Operation(); Decorator objDecorator = new ConcreteDecorator(); objDecorator.SetComponent(obj); objDecorator.Operation(); Decorator objDecorator2 = new ConcreteDecorator2(); objDecorator2.SetComponent(objDecorator); objDecorator2.Operation(); }