Created
March 28, 2017 07:57
-
-
Save nmcc/3f470cf84148c9c8df5abb738f873e4b to your computer and use it in GitHub Desktop.
Singleton .NET Core - Main Transient
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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