Exemplo n.º 1
0
        public static void TestGenericClass()
        {
            IShapeCreator <Shape> sc = RectangleShapeFactory.GetInstance();
            var shape = sc.Create();
            var c1    = shape.TransformWithToken("secret_123", (t) => t.GetHashCode());

            Console.WriteLine($"New token:{c1}");
            var c2 = shape.TransformWithToken(98001, (t) => 2 * t + 1);

            Console.WriteLine($"New token:{c2}");
        }
Exemplo n.º 2
0
        public static void AddShape(Rect rect, ShapeTypes type)
        {
            Connectable shape = null;

            if (creators.ContainsKey(type))
            {
                Type          creatingType = creators[type];
                IShapeCreator creator      = Activator.CreateInstance(creatingType) as IShapeCreator;

                shape = creator.Create(rect) as Connectable;

                AddShape(shape, type);
            }
        }