Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created April 27, 2021 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/9e988751008fc28233e985d30f403645 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/9e988751008fc28233e985d30f403645 to your computer and use it in GitHub Desktop.
Subclass LazyInstance to support delayed instantiation
public class LazyInstance<T>: Lazy<T>
{
public LazyInstance(IServiceProvider serviceProvider)
: base(() => serviceProvider.GetRequiredService<T>())
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment