Example #1
0
        public void Test()
        {
            Console.WriteLine("复合享元模式");

            // 初始化 享元工厂
            FlyweightFactory factory = new FlyweightFactory();

            // 通过享元工厂类来创建享元类
            IFlyweight fly=factory.Factory("abc");
            fly.Operation("罗马字符");

            fly = factory.Factory("bca");
            fly.Operation("阿拉伯字符");

            fly = factory.Factory("cba");
            fly.Operation("阿拉伯字符");

            fly = factory.Factory("abcba");
            fly.Operation("罗马字符ZZZ");
        }
Example #2
0
        public void Test()
        {
            Console.WriteLine("复合享元模式");


            // 初始化 享元工厂
            FlyweightFactory factory = new FlyweightFactory();

            // 通过享元工厂类来创建享元类
            IFlyweight fly = factory.Factory("abc");

            fly.Operation("罗马字符");

            fly = factory.Factory("bca");
            fly.Operation("阿拉伯字符");

            fly = factory.Factory("cba");
            fly.Operation("阿拉伯字符");

            fly = factory.Factory("abcba");
            fly.Operation("罗马字符ZZZ");
        }