Ejemplo n.º 1
0
        /// <summary>
        /// 通过枚举来创建
        /// </summary>
        /// <param name="foodType"></param>
        /// <returns></returns>
        public static AbstractFood CreateInstanceByNormal(SimpleFactorFoodType foodType)
        {
            switch (foodType)
            {
            case SimpleFactorFoodType.Eggplant:
                return(new Eggplant());

            case SimpleFactorFoodType.HotBeef:
                return(new HotBeef());

            case SimpleFactorFoodType.KungPaoChicken:
                return(new KungPaoChicken());

            case SimpleFactorFoodType.Toufu:
                return(new Toufu());

            default:
                throw new Exception("对不起,本店没有这道菜");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据配置文件来创建
        /// </summary>
        /// <param name="foodType"></param>
        /// <returns></returns>
        public static AbstractFood CreateTnstanceByNormalConfigure()
        {
            SimpleFactorFoodType smFoodType = (SimpleFactorFoodType)Enum.Parse(typeof(SimpleFactorFoodType), StaticConstraint.AbstractFoodType);

            return(CreateInstanceByNormal(smFoodType));
        }