public static void Run() { string text = " This is some random text. This needs to be represented in flyweight format"; CharacterContext ctx = new CharacterContext(); foreach (Char c in text) { FlyWeightCharacter fc = FlyWeightFactory.GetInstance().GetCharacter(c); Console.WriteLine(fc.GetFont(ctx)); } }
public string GetFont(CharacterContext ctx) { return(ctx.GetFont()); }
public void SetFont(CharacterContext ctx) { ctx.SetFont("NewFont"); }