[2005] Binary serialization with a fallback class for missing types
My program serializes data provided by plugin objects that always implement my IDocumentContent interface. It is expected that the plugin will have its own data that must be serialized. All IDocumentContent classes must be able to be deserialized, even if the plugin is missing.
I did some testing in another post and found that I get an exception if the plugin is missing.
The IDocumentContent interface includes members that allow a static representation of the data. This was created to allow the data to be shown in a non-interactive way when the plugin is not present.
I'd like to create a MissingPlugin object that the saved data is deserialized to if the plugin is not found. The MissingPlugin object would obviously implement the IDocumentContent interface.
Any ideas how I could create an efficient mechanism that does this? I'm using the BinaryFormatter for performance purposes instead of the XML classes. Something tells me I'm going to have to roll my own formatter. I want to avoid this if possible, but I'm not deadset against it.
To summarize: External class implementing standard interface is serialized on one machine. It is deserialized on another machine that doesn't have the external class. Should instead be deserialized to an internal 'MissingPlugin' class, preferably not losing any plugin specific information (i.e. non-interface members' values) if re-serialized. (If user modifies data: warn user, delete plugin specific data.)
---