Is there a way such that the data access classes inside a repository are updated whenever there is a state change (environment or exception flow encountered) inside a N-tier application? In my program I have the following:
- DAC Repository. Holds a delegate to “observe” the program and update the connection dictionary.
- Connection Dictionary. Lists all of the connection strings per env and rdbms type.
- Business Layer. Encapsulates the data transactions. This one has a constructor accepting the DAC Repository by value.
I suspect this would be a case of pass-by-value issue with the DAC Repository to the BLL, but unsure. The connections work fine with repository and the DACs do get updated if I’m not using the BLL, but once the BLL is integrated, the BLL starts to use only default connections.
Is there something that I might have missed? Should I make the BLL be observing the DAC repository as well?
Perhaps try using IoC container for this? I am not sure I got this correctly, but if you need to observe some settings that might change you can pass a type (or interface) to the constructor of the types that require to observe the settings. Every time you need to apply new settings you just discard an old instance of the type and create a new one passing updated settings.