/// <summary>Construct an instance.</summary> /// <param name="item">The item metadata to copy.</param> public SearchableItem(SearchableItem item) { this.Type = item.Type; this.ID = item.ID; this.CreateItem = item.CreateItem; this.Item = item.Item; }
/// <summary>Create a searchable item if valid.</summary> /// <param name="type">The item type.</param> /// <param name="id">The unique ID (if different from the item's parent sheet index).</param> /// <param name="createItem">Create an item instance.</param> private SearchableItem TryCreate(ItemType type, int id, Func <SearchableItem, Item> createItem) { try { var item = new SearchableItem(type, id, createItem); item.Item.getDescription(); // force-load item data, so it crashes here if it's invalid return(item); } catch { return(null); // if some item data is invalid, just don't include it } }