I want to transfer BusinessObjects from one PC to another. If I think about a number of around 40 different object types to transfer the use of many contracts for the different objects would seem to be quite some overload for always the same task: "Send Object A to Computer B and save object to DB" (objects all have a persistent method).
As the Objects can have many different types, I only want to to use a generic method to:
- serialize a BO object
- transfer it to another PC
- deserialize it with correct type
- make a consistency check
- save to db
- is my problem.
At the moment I'm thinking about sending the type as eytra information. Then I want to do something like:
BinaryFormatter aFormatter = new BinaryFormatter();
aFormatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
Object.ParseTypeFromString(aObjektType) aObject = aFormatter.Deserialize(stream) as Object.ParseTypeFromString(aObjektType);
And afterwards just use generic methods from a base object to save object to database, to keep the transfer classes as simple as possible.
Is there a possibility to do something like this? Or am I going in a completly wrong direction and it would be easier to achieve this task with another approach?