In our ASP.NET project we have a session manager service interface that we use to find out information about the current user. For example:
var actorId = _sessionManager.CurrentActivePerson.PersonId;
This session manager is provided to classes via constructor-based dependency injection.
Now, we have a WCF service that we would like to instantiate with different DI bindings depending on the situation:
- If the consumer has provided a username for the session, we would like to use a session manager that considers that user to be the current person.
- Otherwise, we want to somehow require a domain ID to be provided, use a session manager that is tied to the system person for that domain.
In order for this to work properly, we need to allow the consumer to provide a domain ID as an argument, although it is not specified as an argument of the service itself. We then need to be able to access this argument from a DI binding method while the HostFactory is creating the service instance.
Does anybody have any suggestions on how we might do this?
Notes:
- I already know how to create dependent bindings generally: the question is about passing this extra parameter to the service's factory.
- The WCF service is exposed as a SOAP endpoint, and uses certificate-based security.