Tuesday, March 31, 2020

.AddTransient (in C# and .NET Core) while handing in a variable

Per this, you could have:

services.AddTransient(x => new Yin("yang"));

 
 

...instead of...

services.AddTransient<Yin>();

 
 

And...

services.AddTransient<IYin>(x => new Yin("yang"));

 
 

...instead of...

services.AddTransient<IYin, Yin>();

 
 

I do not yet know what is going on with IOperationSingletonInstance here. I could not figure it out.

No comments:

Post a Comment