public static void FirstDemo() { int extrinsicstate = 22; FlyWeightFactory factory = new FlyWeightFactory(); // Work with different flyweight instances FlyWeight fx = factory.GetFlyWeight("X"); fx.Operation(--extrinsicstate); FlyWeight fy = factory.GetFlyWeight("Y"); fy.Operation(--extrinsicstate); FlyWeight fz = factory.GetFlyWeight("Z"); fz.Operation(--extrinsicstate); UnsharedConcreteFlyweight fu = new UnsharedConcreteFlyweight(); fu.Operation(--extrinsicstate); // Wait for user Console.ReadKey(); }
public static void Main(string[] args) { var counter = 20; var factory = new FlyWeightFactory(); factory.GetFlyweight("X").Operation(counter--); factory.GetFlyweight("Y").Operation(counter--); new UnsharedFlyweight().Operation(counter--); Console.WriteLine(counter); Console.ReadLine(); }