private static void Operation(Car car) { Console.WriteLine("\nClient: Adding a car to database."); var flyweight = FlyweightFactory.GetFlyweight(new Car { Color = car.Color, Model = car.Model, Company = car.Company }); flyweight.Operation(car); }
public static void Test() { HashSet <string> colors = new HashSet <string> { "red", "green", "blue" }; HashSet <string> shades = new HashSet <string> { "pale", "dark", "light" }; FlyweightFactory factory = new FlyweightFactory(); foreach (string s in shades) { foreach (string c in colors) { Flyweight flyweight = factory.GetFlyweight(c); System.Console.WriteLine(flyweight.DoSomething(s)); } } System.Console.WriteLine("Number of Flyweights: " + factory.GetFlyweightsNumber()); }