Skip to content

Instantly share code, notes, and snippets.

@nmcc
Created March 28, 2017 07:57
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 nmcc/3f470cf84148c9c8df5abb738f873e4b to your computer and use it in GitHub Desktop.
Save nmcc/3f470cf84148c9c8df5abb738f873e4b to your computer and use it in GitHub Desktop.
Singleton .NET Core - Main Transient
var serviceProvider = new ServiceCollection()
.AddTransient<ImageStore>((ctx) =>
{
var imageStore = new ImageStore();
for (int i = 0; i < 10; i++) imageStore.AddImage($"image_{i}", File.ReadAllBytes("potato.png"));
return imageStore;
})
.BuildServiceProvider();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment