Skip to content
Discussion options

You must be logged in to vote

Recommend not using a static IServiceProvider. If you run into this issue, I think it is a potential sign that you should consider a bit of refactoring.

Here are a number of better options, in my opinion:

  • Injecting the service into the ViewModel, and then exposing another property that provides the processed data.
  • If there is a reason you wanted to delay injecting the service directly into the ViewModel, then inject IServiceProvider into the constructor of the ViewModel, and do the same thing as above.
  • Make more pages and custom components as needed, and do the transformations inside of those. Having nested custom components inside of a page that have their own ViewModel is a perfectly g…

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@symbiogenesis
Comment options

@symbiogenesis
Comment options

@sigged
Comment options

@FM1973
Comment options

@symbiogenesis
Comment options

Comment options

You must be logged in to vote
2 replies
@sigged
Comment options

@symbiogenesis
Comment options

Answer selected by symbiogenesis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants