I'm building a shared state application in which a WCF server application aggregates data from disparate sources into a single data model, which it then synchronises with clients. It provides each client with an initial snapshot of the model, then sends deltas, as each model property in the model. As a result the state is shared across all the clients.
Because the model is volatile, each delta needs to be a deep copy of a data model property, which can include complex objects with nested properties. As soon as the property changes, a copy is made and passed to the client queue handler. It has to be a copy - I can't pass a reference to the property, as it may well change during the serialisation process. Locking the model while the delta is passed to each client is not desirable. I want the main thread of the application freed up as soon as the copy is made.
My question is how to combine the deep copy with WCF wire serialisation in the most effective way. A quick and cheap way to create the deep copy of each delta would be to use the DataContractSerializer class. Because this is normally used in WCF serialisation, it feels like this could save time in serialising the delta for transport to the clients - perhaps there is a way of doing both things in one operation. So I'm looking for a way to suspend serialisation for a particular OperationContract method on a duplex callback interface. In effect I'm looking for a way to tell the binding 'Don't serialise the parameter value for this OperationContract method - it has already been serialised using the DataContractSerializer - please just pass it straight to the client. Because I'm using a Silverlight client, the binding I'm using is PollingDuplexHttpBinding.