I have StructureMap set-up to pass in dependencies as interfaces for handling different email protocols. The implementations however inherit from ‘TcpClient’. If there is an error or disconnection, a re-connect cannot occur unless a new TcpClient has been created, therefore the dependency passed in needs to be refreshed with a new object.
How do I go about getting StructureMap to re-create the dependencies that have already been passed in?
Within the service constructor, 2 of these protocol interfaces need to be refreshed with new objects.
It would be nice if StructureMap can accomplish this without making any calls to ObjectFactory as the dependencies have already been wired up in the ServiceRegistry class.
Sounds like a custom lifestyle might do the trick. This is done by implementing the
ILifecycleinterface.