Aeon Vex
❔ Catching an error status code in HTML agility pack when using LoadFromWebAsync
I'm using HTML agility pack to request multiple web pages simultaneously. I'm struggling to see how I can safely do error handling when using
LoadFromWebAsync()
however, given that the returned result does not include any status code, and the only way to check the http response code is via a callback on the HtmlWeb instance or via a public property. Is there a way I can catch and handle http error codes in a thread safe way?
The only option I see would be to use the HtmlWeb.PostResponse
callback, but I'm not sure how I could use that to cleanly handle error status codes in those specific tasks.2 replies
Implementing an inventory system with right click actions
This is really a hypothetical question as I'm not working on anything like this at the moment, but I've wonder in the past what the best way to approach this would be and haven't been able to come up with any good resources.
Let's say I'm making a game, and the game design required an inventory system. The main thing this system should allow for is the following:
1. It should be able to keep track of items, naturally. For simplicity's sake, no item stacking is allowed, so singular items only.
2. Items should have actions that you can execute via a right click menu, e.g. "Consume" for consumables, "Equip" for equippables, and "Drop" for all.
The first solution that comes to mind is creating a base class / interface for
Item
, and for each type of item having a derived type, e.g. Consumable
and Equippable
. These are then kept in a List<Item>
, for example. The drop action could then be added to the right click menu (exact implementation not important) as it would apply to all items, and would perhaps be implemented in the Inventory
class itself.
With this setup, what would be the "right" way to implement actions that are specific to certain types of items? Presumably the right click menu would be populated like this:
Would it make sense to have the classes deriving from item define which actions should be added to the menu? If not, how would you go about fetching valid actions for any given Item
?
Alternatively, does all I've mentioned above make sense, or would an entirely different structure be preferred here?
Any hints on where to start looking for this kind of design would also be appreciated.20 replies