public int GetOrCreateItemIdForAuction(SaveAuction auction, HypixelContext context) { var clearedName = ItemReferences.RemoveReforgesAndLevel(auction.ItemName); var tag = GetIdForName(auction.Tag ?? clearedName); if (tag != null && TagLookup.TryGetValue(tag, out int value)) { return(value); } Console.WriteLine($"Creating item {clearedName} ({auction.ItemName},{auction.Tag})"); // doesn't exist yet, create it var itemByTag = context.Items.Where(item => item.Tag == auction.Tag).FirstOrDefault(); if (itemByTag != null) { // new alternative name if (clearedName != null) { this.ReverseNames[clearedName] = auction.Tag; } TagLookup.Add(auction.Tag, itemByTag.Id); var exists = context.AltItemNames .Where(name => name.Name == clearedName && name.DBItemId == itemByTag.Id) .Any(); if (!exists) { context.AltItemNames.Add(new AlternativeName() { DBItemId = itemByTag.Id, Name = clearedName }); } return(itemByTag.Id); } Console.WriteLine($"!! completely new !! {JsonConvert.SerializeObject(auction)}"); // new Item //var tempAuction = new Hypixel.NET.SkyblockApi.Auction(){Category=auction.Category,}; //AddNewItem(tempAuction,auction.ItemName,auction.Tag,null); var item = new DBItem() { Tag = auction.Tag, Name = auction.ItemName, Names = new List <AlternativeName>() { new AlternativeName() { Name = auction.ItemName } } }; if (item.Tag == null) { // unindexable item return(MAX_MEDIUM_INT); } ToFillDetails[item.Tag] = item; return(AddItemToDB(item)); //throw new CoflnetException("can_add","can't add this item"); }
/// <summary> /// /// Tries to get the card list for a given dictionary key. Generic so that the key can be suited for any of the constructed dictionaries /// /// </summary> public List <CardData> GetDictionaryList <T>(T key, CardFilter listFilter = null) { var dictionaryList = new List <CardData>(); var type = typeof(T); switch (type) { case Type _ when type == typeof(Tags): TagLookup.TryGetValue((Tags)(object)key, out dictionaryList); break; case Type _ when type == typeof(Synergies): SynergyLookup.TryGetValue((Synergies)(object)key, out dictionaryList); break; case Type _ when type == typeof(Classes.ClassList): ClassLookup.TryGetValue((Classes.ClassList)(object) key, out dictionaryList); break; case Type _ when type == typeof(ClassResources): ClassPlayableLookup.TryGetValue((ClassResources)(object)key, out dictionaryList); break; case Type _ when type == typeof(CardResources): ResourceLookup.TryGetValue((CardResources)(object)key, out dictionaryList); break; case Type _ when type == typeof(Sets): SetLookup.TryGetValue((Sets)(object)key, out dictionaryList); break; case Type _ when type == typeof(Rarity): RarityLookup.TryGetValue((Rarity)(object)key, out dictionaryList); break; case Type _ when type == typeof(CardTypes): TypeLookup.TryGetValue((CardTypes)(object)key, out dictionaryList); break; default: throw new Exception("Not a valid Dictionary Type"); } if (dictionaryList != null) { if (listFilter != null) { return(FilterCardList(dictionaryList.OrderCardList(), listFilter)); } else { return(dictionaryList.OrderCardList()); } } else { return(new List <CardData>()); } }
// Static Methods /// <summary> /// Gets the tag identified by the given globally unique identifier. /// </summary> /// <param name="id">The globally unique identifier for the tag to be retrieved.</param> /// <returns>The tag, if defined, or null if the tag is not found.</returns> /// <exception cref="InvalidDataException">Unable to refresh tags from TagDefinitions.xml.</exception> public static Tag?GetTag(Guid id) { if (TagLookup == null) { RefreshTags(TagDefinitions); } if (TagLookup == null) { throw new InvalidDataException($"Unable to refresh tags from {TagDefinitionsFileName}."); } if (!TagLookup.TryGetValue(id, out Tag tag)) { return(null); } return(tag); }
/// <summary> </summary> public override void StartTag(XmlTagInfo tag) { if (_nonClosedTags.Contains(tag.FullName)) { tag.SelfClosed = true; } XmlLightElement parent = _parserStack.Peek(); List <string> allowedParents; if (_nonNestingTags.Contains(tag.FullName) && StringComparer.OrdinalIgnoreCase.Equals(parent.TagName, tag.FullName)) { _parserStack.Pop(); } else if (_htmlHeirarchy.TryGetValue(tag.FullName, out allowedParents)) { int depth = 0; XmlLightElement[] stack = _parserStack.ToArray(); while (depth < stack.Length && allowedParents.BinarySearch(stack[depth].TagName, StringComparer.OrdinalIgnoreCase) < 0) { depth++; } if (depth < stack.Length) { for (; depth > 0; depth--) { _parserStack.Pop(); } } else { StartTag(new XmlTagInfo(allowedParents[0], false)); } } base.StartTag(tag); }