public PizzaOrderStrategy(List <IProduct> products, IngredientMap ingredientMap, SizeMap sizeMap, IOrderStrategy nextStrategy) { _products = products; _ingredientMap = ingredientMap; _sizeMap = sizeMap; _nextStrategy = nextStrategy; }
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; } }
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(); }
public ScoreCalculator(ICardValueStrategy valueStrategy = null, IOrderStrategy order = null) { _valueStrategy = valueStrategy ?? new AceLowFaceTenCardValueStrategy(); _order = order ?? new StandardOrder(); }
private Order(List <IProduct> products, IOrderStrategy orderStrategy) { _products = products; _orderStrategy = orderStrategy; }
public void setStrategy(IOrderStrategy strategy) { currentStrategy = strategy; }