Пример #1
0
        public void Test()
        {
            Console.WriteLine("单纯享元模式");

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

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

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

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

            fly = factory.Factory('b');
            fly.Operation("罗马字符");
        }
Пример #2
0
        public void Test()
        {
            Console.WriteLine("单纯享元模式");


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

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

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

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

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

            fly = factory.Factory('b');
            fly.Operation("罗马字符");
        }