I have a modular application built using the Unity container. Modules are registered in app.config but each module adds additional elements that are persisted as part of the user profile upon application shutdown. I want to be able to serialize any element into the user profile based on those modules currently loaded, as each module provides a profile element.
Upon application shutdown, I interogate each module to provide its list of types, which I then combine together and pass to the DataContractSerializer constructor. This works well upon application shutodnw. However, upon application startup, when attempting to deserialize the user profile, I need to get this list of types in order to be able to completely deserialize the user profile.
I have tried several approaches:
- Loading Assemblies in ReflectionOnly mode using information obtained from Microsoft.Practies.Composite.Modularity.ModuleInfo class and then retrieving all types that implement a defined interface. This did not work as I cannot GetTypes when an assembly is loaded in ReflectionOnly.
Then I tried loading the assembly fully but ModuleInfo provides only the Assembly's partial name, so none of the Assembly.LoadXXX methods and overloads works. I can probably get this going but decided to stop for a minute and evaluate this approach as this sounds like a jack.
- Save string collection of knonw types into a different object that is persisted outside of the user profile. Opon application startup, I will have to retrieve this profile meta data before retrieving profile from the server. Sounds like another hack job to me.
How would you guys approach this?
TIA.