コード例 #1
0
        /// <summary>
        /// 复合享元工厂方法,所需状态以参量形式传入,这个参量巧好可以使用string类型  
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        public IFlyweight Factory(string compositeState)
        {
            ConcreteCompositeFlyweight compositeFly = new ConcreteCompositeFlyweight();

            for (int i = 0; i < compositeState.Length; i++)
            {
                compositeFly.Add(this.Factory(compositeState[i]));
            }
            return compositeFly;
        }
コード例 #2
0
        /// <summary>
        /// 复合享元工厂方法,所需状态以参量形式传入,这个参量巧好可以使用string类型
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        public IFlyweight Factory(string compositeState)
        {
            ConcreteCompositeFlyweight compositeFly = new ConcreteCompositeFlyweight();

            for (int i = 0; i < compositeState.Length; i++)
            {
                compositeFly.Add(this.Factory(compositeState[i]));
            }
            return(compositeFly);
        }