Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to initiate class having dependency. #3018


User avatar
0
priteshsanipara created

I have Job helper class. I need to call it from static class. How to I call SendNotifications() from other class. How to created the object of JobHelper class.

public class JobHelper : ITransientDependency { private readonly ILogger Logger; private readonly IAppUserService _appUserService;

    public JobHelper(ILogger logger, IAppUserService appUserService)
    {
        Logger = logger;
        _appUserService = appUserService;
    }

public async Task SendNotifications(CreateNotificationsInput notificaton) { var users = await _appUserService.GetUsersForNotification(input); }

}


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can resolve your class directly using IocManager. For example:

    IocManager.Instance.IocContainer.Resolve<JobHelper>();