-
Notifications
You must be signed in to change notification settings - Fork 757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Dependency Injection from Scheduler #3602
Comments
I am not an expert at DI and I did not build code samples to test this so just asking questions :) I was under the impression that we use Microsoft one unaltered so that something like:
would just work out of the box... Right? Now for the forum post at hand, the major issue (which is not new) is that the scheduler has no HTTP Context and one needs to use another way to obtain the portalId (configuration, settings, etc.) to get a PortalInfo object manually from code. |
DNN currently supports constructor injection in 1️⃣ Web API controllers, 2️⃣ MVC controllers, 3️⃣ Razor models, and it supports "service location" in WebForms via Anywhere else that DNN is creating new instances of classes, dependency injection (neither constructor injection nor service location) is not yet supported. In this particular case, creating a Dnn.Platform/DNN Platform/Library/Services/Scheduling/ProcessGroup.cs Lines 157 to 173 in c35fdc7
|
This one could be a bit interesting since we have an architecture requirement with the first parameter being the ScheduleHistoryItem. It is possible that we might have to do something different for this to support DI. |
You could use Another note, to preserve the lifetime of scoped services resolved in this manner (see details about the pitfalls of MS DI) you should open a scope from the |
Description of problem
There is no way to access services in the Dependency Injection container from a scheduler client.
Description of solution
When DNN creates a scheduler client, it needs to use the DI container.
Additional context
Based in a discussion at https://dnncommunity.org/forums/aft/890 and via https://dnntag.slack.com/
The text was updated successfully, but these errors were encountered: