I have a service object that does some work on a particular patient.
public class PatientDxService
{
public Patient Patient { get; set; }
public PatientDxService(Patient patient)
{
this.Patient = patient;
}
}
My service takes in a Patient object as shown above.
I have a SessionManager object that has a property to get the session Patient. I want to inject the patient.
Bind<PatientDxService>().ToConstructor(x => new PatientDxService(x.Inject<ISessionManager>().Patient));
Bind<ISessionManager>().To<SessionManager>().InSingletonScope();
The above does not work for me. I don’t really want to inject ISessionManager because if I wanted to use the services outside of the web scope, it wouldn’t make sense.
Inject the ISessionManager into your Service instead of the Patient. then in constructor (or better yet, where you actually use the Patient), request the Patient from the session.