/// <summary>
        /// 根据名称获取策略类
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static IGradeStrategy GetGradeStrategy(string key)
        {
            Type type = gradeStrategies[key];

            if (type == null)
            {
                throw new ArgumentException(key + "无效");
            }
            IGradeStrategy strategy = Activator.CreateInstance(type) as IGradeStrategy;

            strategy.Name = key;
            return(strategy);
        }
Esempio n. 2
0
    protected void Button30_Click(object sender, EventArgs e)
    {
        StrategySet set = new StrategySet();

        IGradeStrategy strategy = StrategyFactory.GetGradeStrategy(this.DropDownList1.SelectedValue);

        strategy.Value = this.DropDownList2.SelectedValue;


        this.Label4.Text = strategy.BuildQuery();

        CustomerGrade cg = new CustomerGrade();

        cg.CompanyID  = 2;
        cg.GradeLevel = UserLevel.D;
        cg.GradeLimit = strategy.BuildQuery();
        CustomerGradeManager.Create(cg);
    }