/// <summary> /// The test second. /// </summary> private static void TestSecond() { // Arbitrary extrinsic state int extrinsicstate = 22; FlyweightFactory flyweightFactory = new FlyweightFactory(); // Work with different flyweight instances AbstractFlyweight fx = flyweightFactory.GetFlyweight("X"); fx.Operation(--extrinsicstate); AbstractFlyweight fy = flyweightFactory.GetFlyweight("Y"); fy.Operation(--extrinsicstate); AbstractFlyweight fz = flyweightFactory.GetFlyweight("Z"); fz.Operation(--extrinsicstate); UnsharedConcreteFlyweight fu = new UnsharedConcreteFlyweight(); fu.Operation(--extrinsicstate); // Wait for user Console.ReadKey(); }
static void Main(string[] args) { int extrinsicstate = 22; FlyWeightFactory factory = new FlyWeightFactory(); 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); Console.ReadKey(); }