示例#1
0
 public PizzaOrderStrategy(List <IProduct> products, IngredientMap ingredientMap, SizeMap sizeMap, IOrderStrategy nextStrategy)
 {
     _products      = products;
     _ingredientMap = ingredientMap;
     _sizeMap       = sizeMap;
     _nextStrategy  = nextStrategy;
 }
示例#2
0
        public OrderContext(OrderTypeE orderTypeE, IMapper mapper)
        {
            this._mapper = mapper;
            switch (orderTypeE)
            {
            case OrderTypeE.扫码点餐订单:
                this.strategy = new ShopOrderStrategy(_mapper);
                break;

            case OrderTypeE.外卖订单:
                this.strategy = new TakeOutOrderStrategy(_mapper);
                break;

            case OrderTypeE.自助点餐订单:
                strategy = new SelfHelpStrategy(_mapper);
                break;

            case OrderTypeE.拼团订单:
                this.strategy = new ConglomerationOrderStrategy(_mapper);
                break;

            default:
                this.strategy = new TakeOutOrderStrategy(_mapper);
                break;
            }
        }
示例#3
0
        private static IOrderStrategy _iorderstrategy = null;//订单策略

        static BMAOrder()
        {
            try
            {
                string[] fileNameList = Directory.GetFiles(System.Web.HttpRuntime.BinDirectory, "BrnMall.OrderStrategy.*.dll", SearchOption.TopDirectoryOnly);
                _iorderstrategy = (IOrderStrategy)Activator.CreateInstance(Type.GetType(string.Format("BrnMall.OrderStrategy.{0}.OrderStrategy, BrnMall.OrderStrategy.{0}", fileNameList[0].Substring(fileNameList[0].IndexOf("OrderStrategy.") + 14).Replace(".dll", "")),
                                                                                        false,
                                                                                        true));
            }
            catch
            {
                throw new BMAException("创建'订单策略对象'失败,可能存在的原因:未将'订单策略程序集'添加到bin目录中;'订单策略程序集'文件名不符合'BrnMall.OrderStrategy.{策略名称}.dll'格式");
            }
        }
示例#4
0
        private static IOrderStrategy _iorderstrategy = null;//订单策略

        static BMAOrder()
        {
            try
            {
                string[] fileNameList = Directory.GetFiles(System.Web.HttpRuntime.BinDirectory, "BrnMall.OrderStrategy.*.dll", SearchOption.TopDirectoryOnly);
                _iorderstrategy = (IOrderStrategy)Activator.CreateInstance(Type.GetType(string.Format("BrnMall.OrderStrategy.{0}.OrderStrategy, BrnMall.OrderStrategy.{0}", fileNameList[0].Substring(fileNameList[0].IndexOf("OrderStrategy.") + 14).Replace(".dll", "")),
                                                                                        false,
                                                                                        true));
            }
            catch
            {
                throw new BMAException("创建'订单策略对象'失败,可能存在的原因:未将'订单策略程序集'添加到bin目录中;'订单策略程序集'文件名不符合'BrnMall.OrderStrategy.{策略名称}.dll'格式");
            }
        }
        public OrderStrategyContext()
        {
            strategies = new Dictionary <ShippingTypes, IOrderStrategy>();
            //strategies.Add(ShippingTypes.Aramex, new AramexStrategy());
            //strategies.Add(ShippingTypes.DHL, new DHLStrategy());
            //strategies.Add(ShippingTypes.FedEx, new FedExStrategy());
            var allTypes = Assembly.GetExecutingAssembly().GetTypes(); //Reflection

            foreach (var strategy in allTypes)
            {
                if (strategy.GetInterface("IOrderStrategy") != null)
                {
                    IOrderStrategy st = Activator.CreateInstance(strategy) as IOrderStrategy;
                    strategies.Add(st.ShippingType, st);
                }
            }
        }
 public LowestCardPlayStrategy(IOrderStrategy orderStrategy = null)
 {
     _orderStrategy = orderStrategy ?? new StandardOrder();
 }
示例#7
0
 public ScoreCalculator(ICardValueStrategy valueStrategy = null, IOrderStrategy order = null)
 {
     _valueStrategy = valueStrategy ?? new AceLowFaceTenCardValueStrategy();
     _order = order ?? new StandardOrder();
 }
示例#8
0
 private Order(List <IProduct> products, IOrderStrategy orderStrategy)
 {
     _products      = products;
     _orderStrategy = orderStrategy;
 }
示例#9
0
 public void setStrategy(IOrderStrategy strategy)
 {
     currentStrategy = strategy;
 }