Not Mark
Static helper class/method design question
For testability's sake, I'd personally make this a non-static class with an interface (with
_pathCache
being a non-static field). You can then register this class as a singleton to be injected into your other classes.
Then for the FillCache
method, you can either call that in the constructor (although typically you would avoid complex logic like that in a constructor) or maybe call it when registering your class.7 replies
405 Method Not Allowed
From the error it sounds like whatever endpoint you're trying to hit doesn't support whatever http method you're sending.
This suggests you're sending a POST, but does that endpoint actually support a POST? Or if it does, does the
PostAsJsonAsync
method actually send it as a POST?8 replies
❔ ✅ Help with searching a class of classes for something?
Assuming you have this sort of structure:
Then you would need to iterate over over every
MiddleClass
inside of StartingClass
's list, and inside each one of those MiddleClass
object, iterate over that list until you find your target. So something like:
If the nesting of your classes is more "deep" you would just add more for loops.4 replies
Text.Json Error
I guess there are several ways to handle this. One way is to read the string
response.Content
and manually remove the " quotes at the beginning and end, and then deserialize. You could also deserialize response.Content
into a string first and then deserialize that string into your Player[]
. I just tested this way and it seems to work. I don't know if that's the best way of handling that though... lol53 replies