static void Main(string[] args) { IComponent componentX_WithNoDecorator = new ComponentX(); componentX_WithNoDecorator.MethodA(); IComponent componetX_WithDecoratorA = new DecoratorA(componentX_WithNoDecorator); componetX_WithDecoratorA.MethodA(); IComponent componentX_WithDecoratorA_And_DecoratorB = new DecoratorB(componetX_WithDecoratorA, new DataService(), 4); Console.WriteLine(componentX_WithDecoratorA_And_DecoratorB.MethodB()); Console.ReadLine(); }
// Implementation of ICustomTypeDescriptor: PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() { // Create a collection object to hold property descriptors PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); for (int i = 0; i < Count; i++) { ComponentX comp = this[i] as ComponentX; if (comp != null) { pds.Add(new ItemPropertyDescriptor <T>(this, i, comp.Name)); } else { pds.Add(new ItemPropertyDescriptor <T>(this, i, i.ToString())); } } return(pds); }
public Service(ComponentX x, ComponentY y) { X = x; Y = y; }