/// <summary> /// 武神塔获得物品 /// </summary> /// <param name="id"></param> /// <returns></returns> public static List <Goods> GetKungfuGodReward(uint id) { List <Goods> goodsList = new List <Goods>(); List <string> data_secret_area = DBManager.Instance.QuerySqliteField <string>(GlobalConfig.DBFile, "data_secret_area", "id", id.ToString(), "goods"); if (data_secret_area.Count == 0) { return(goodsList); } string raw = data_secret_area[0]; raw = raw.Replace(" ", ""); var matchs = Regex.Matches(raw, @"\{(\d+),(\d+)\}"); foreach (Match _match in matchs) { if (_match.Success) { uint goodsid = DBTextResource.ParseUI(_match.Groups[1].Value); uint goodsnum = DBTextResource.ParseUI(_match.Groups[2].Value); Goods goods = GoodsFactory.Create(goodsid, null); if (goods != null) { goods.num = goodsnum; goodsList.Add(goods); } } } return(goodsList); }
public void Main() { var goods = GoodsFactory.Create(GoodsType.Character, 1); goods = GoodsFactory.Create(GoodsType.Box, 1); goods = GoodsFactory.Create(GoodsType.Weapon, 1, 2); }
public GoodsModel ToModel(GoodsEntity goods) { var factory = new GoodsFactory(); var convertedGoods = factory.GetGoods(goods.Type); convertedGoods.Id = goods.Id; convertedGoods.Name = goods.Name; convertedGoods.Price = goods.Price; return(convertedGoods); }
public void TownInitialize() { races = new List <RaceEntity>(); races.Add(RaceFactory.Create("Race_01", RaceType.HUMAN)); goods = new List <GoodsEntity>(); goods.Add(GoodsFactory.Create(GoodsType.FLOUR, "小麦")); var building = new SimpleProducer("農場", new ProduceAbility(goods.First(), 10), 5); townEntity = TownFactory.Create(0, "town_01", TownType.INLAND, races.First()); townEntity.Build(0, building); }
public static int constructor(IntPtr l) { int result; try { GoodsFactory o = new GoodsFactory(); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public void AddGoods(GoodsDTO goodsDTO, string creatorId) { var goodsImages = goodsDTO.GoodsImages.Select(item => new GoodsImage { CreatedOn = DateTime.Now, ImageId = item.ImageId }).ToList(); var grouponConditions = goodsDTO.GrouponConditions.Select(item => new GrouponCondition { MoreThanNumber = item.MoreThanNumber, Price = item.Price }).ToList(); var obj = GoodsFactory.CreateGoods( goodsDTO.ItemNumber, goodsDTO.Category, goodsDTO.SubCategory, goodsDTO.Title, goodsDTO.Description, goodsDTO.Detail, goodsDTO.UnitPrice, goodsDTO.MarketPrice, goodsDTO.Unit, goodsDTO.Stock, goodsDTO.StoreId, creatorId, goodsDTO.OptionalPropertyJsonObject, grouponConditions, goodsImages, goodsDTO.Address, goodsDTO.DistributionScope, goodsDTO.GoodsCategoryName, goodsDTO.VideoPath); _goodsRepository.Add(obj); goodsImages.ForEach(item => { _goodsImageRepository.Add(item); }); grouponConditions.ForEach(item => { _grouponConditionRepository.Add(item); }); _dbUnitOfWork.Commit(); }
public static int CloneGoods_s(IntPtr l) { int result; try { List <Goods> goods; LuaObject.checkType <List <Goods> >(l, 1, out goods); List <Goods> o = GoodsFactory.CloneGoods(goods); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public async Task <BaseApiResult <bool> > Excute(CreateGoodsDto input) { return(await HandleAsync(input, async() => { //工厂创建商品聚合 var goods = new GoodsFactory().Create(input.Name, input.Price, input.ImageId, input.Stock); //创建商品规约检查 if (await new CreateGoodsSpecification(goodsRepository).SatisfiedBy(goods)) { //仓储添加 goodsRepository.Add(goods); await goodsRepository.SaveAsync(); var proxy = serverProxyFactory.CreateProxy <IGoodsActor>(goods.Id); await proxy.Add(goods);//创建actor对象到缓存里 return true; } return false; })); }
public void Create_Returns_NonImportedGood_Given_Valid_GoodsInfo() { //Arrange string category = "general"; int quantity = 1; string name = "music CD"; double price = 15.50; IGoodsFactory target = new GoodsFactory(); //Act IGoods actual = target.Create(category, quantity, name, price); //Assert Assert.AreEqual(actual.Name, name); Assert.AreEqual(actual.Price, price); Assert.AreEqual(actual.Quantity, quantity); Assert.IsInstanceOf <Goods>(actual, typeof(Goods).ToString()); }
public void Create_Returns_TaxExemptGood_Given_Valid_TaxExemptGoodInfo() { //Arrange string category = "books"; int quantity = 1; string name = "cook book"; double price = 12.15; IGoodsFactory target = new GoodsFactory(); //Act IGoods actual = target.Create(category, quantity, name, price); //Assert Assert.AreEqual(actual.Name, name); Assert.AreEqual(actual.Price, price); Assert.AreEqual(actual.Quantity, quantity); Assert.IsInstanceOf <TaxExemptGood>(actual, typeof(TaxExemptGood).ToString()); }
public void Create_Returns_ImportedTaxExemptGood_Given_Valid_ImportedTaxExemptGoodInfo() { //Arrange string category = "food"; int quantity = 1; string name = "imported chocolate"; double price = 10.50; IGoodsFactory target = new GoodsFactory(); //Act IGoods actual = target.Create(category, quantity, name, price); //Assert Assert.AreEqual(actual.Name, name); Assert.AreEqual(actual.Price, price); Assert.AreEqual(actual.Quantity, quantity); Assert.AreEqual(actual.Imported, true); Assert.IsInstanceOf <TaxExemptGood>(actual, typeof(TaxExemptGood).ToString()); }
public static int CreateGoods_s(IntPtr l) { int result; try { GoodsType goodsTypeId; LuaObject.checkEnum <GoodsType>(l, 1, out goodsTypeId); int contentId; LuaObject.checkType(l, 2, out contentId); int nums; LuaObject.checkType(l, 3, out nums); Goods o = GoodsFactory.CreateGoods(goodsTypeId, contentId, nums); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public List <List <IGoods> > CreateShoppingCart(string inputFilePath) { var factory = new GoodsFactory(); List <List <IGoods> > shoppingCart = new List <List <IGoods> >(); List <string> categoriesList = new List <string>() { "general", "books", "food", "medical" }; List <IGoods> temp = new List <IGoods>(); string[] inputText = null; while (inputText == null) { try { inputText = File.ReadAllLines(@inputFilePath); } catch (Exception e) { Console.Write("File was not found. Please enter the correct file path: "); inputFilePath = Console.ReadLine(); } } foreach (string input in inputText) { string entry = input.ToLower(); if (entry.ToLower().Contains("input")) { temp = new List <IGoods>(); continue; } if (entry.StartsWith(" ")) { shoppingCart.Add(temp); continue; } try { string separator = "at"; int split = entry.LastIndexOf(separator); string info = entry.Substring(0, split); string priceString = entry.Substring(split).Remove(0, 3); int quantityPosition = info.IndexOf(' ') + 1; string category = info.Substring(0, quantityPosition - 1); if (!categoriesList.Contains(category)) { throw new InvalidCategoryException("Invalid Category, please refer to the categories provided and try again."); } int quantity = Int32.Parse(info.Substring(quantityPosition, 1)); string nameString = info.Substring(quantityPosition + 1).TrimStart(); double price = Double.Parse(priceString); temp.Add(factory.Create(category, quantity, nameString, price)); } catch (Exception e) { if (e is InvalidCategoryException) { Console.WriteLine(e.Message); } else { Console.WriteLine("Invalid Entry, please refer to the correct format above."); } } } shoppingCart.Add(temp); return(shoppingCart); }
public CreateGoodsCommandHandler(IDbContext dbContext, GoodsFactory goodsFactory, IGoodsRepository goodsRepository) : base(dbContext) { this.goodsFactory = goodsFactory; this.goodsRepository = goodsRepository; }