How to inject CSLA classes into a class library of a Quartz project? #3923
-
Hello everyone, I have a Quartz Server project where I register my Csla interfaces and another project, which is a class library where I define the jobs that execute. This latter project has many classes, and I'm not sure how to inject a property as I do in Blazor Razor pages, something like:
Any help on how to inject the Csla classes into a class library of a Quartz project is appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
This is probably a question you'll need to ask the Quartz Server users or support: how do I inject a dependency into a job or task class? I had never heard of Quartz Server until today when I looked it up for this question. I'm going to guess that when you create a job, that job is a class? Hopefully they support DI, and allow you to do something like this: public class MyJob
{
public MyJob(IDataPortal<ProjectEdit> portal)
{
_portal = portal;
}
private IDataPortal<ProjectEdit> _portal;
public async Task DoTheJob()
{
var project = await _portal.FetchAsync(123);
{
} |
Beta Was this translation helpful? Give feedback.
-
I think you'll need either Spring or Google Guice for JAVA (or some other DI framework) then use the @Inject attribute on the property you want to inject. But I think you'll need to do this in JAVA for Quartz since it's a JAVA based job scheduler. But the information I'm giving you should be considered a WAG. |
Beta Was this translation helpful? Give feedback.
@rockfordlhotka,
After making all the service registrations, I added this line of code:
builder.Services.AddCsla();
And magically, the following line worked and stopped returning null:
var cslaFactory = scope.ServiceProvider.GetService<IDataPortal>();
Thank you very much for the help.