I’m using a UnityContainer.
I want to register in it AuthService and TokenManager.
AuthService has TokenManager as a private memeber.
TokenManager has one ctor: TokenManager(string name, string pass)
I get these strings from the UI at runtime.
Unity require to register ctor parameters in a config file.
I have thought
- to create a ctor:
AuthService(TokenManager mgr)
But then how do I add an object (non-primitive) to the <unity> node in the config file?
- How can I still use Unity with runtime parameter to
TokenManagerctor?
My idea:
AuthService will have two ctor – parameterless and
AuthService(bool initFromContainer)In test harness I will call new AuthService(false) and then override the TokenManager
using AuthService_Accessor