Exemple #1
0
        // change to Main to run.
        public static void none(string[] args)
        {
            var redSquare = new ColoredShape <Square2>();

            Console.WriteLine(redSquare.AsString());

            // use this because constructor forwarding doesn't work in c#
            // quasi static composition using aggregation many nested objects carry instantiations of other objects.
            var circle = new TransparentShape <ColoredShape <Circle2> >(0.4f);

            Console.WriteLine(circle.AsString());
        }
        // change to Main to run.
        public static void none(string[] args)
        {
            var square = new Square(1.23f);

            Console.WriteLine(square.AsString());

            var redSquare = new ColoredShape("red", square);

            Console.WriteLine(redSquare.AsString());

            // Nested composed decorators, works at runtime.
            var redHalfTransparentSquare = new TransparentShape(redSquare, 0.5f);

            Console.WriteLine(redHalfTransparentSquare.AsString());
        }