When instantiating a class from the IServiceProvider.GetService
I want to inject an instance that I created earlier in the request into the create function.
var transintObject = new SomeObjec();
var other = serviceProvider.GetService<RegisterdService>(transientObject)
I know RegisterdService
is dependent on SomeObject
but right now I'm not able to register the construction of the SomeObject
in the DIContainer.
可以使用Activatorutilities.CreateInstance
修复此问题
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.