for some reasons I need to control the process of object serialization in .NET. I have to control that properties should be serialized. This process should be dynamical so, at one request one set of properties should be serialized and at the other one – another. I’m curious is it possible to implement by the already existed mechanism or I have to design some custom serializer?
Share
The
ISerializableinterface allows you to do exactly that. Basically, you control which values are added to the “property bag” (SerializationInfo) when the serialization is being performed. Notice that you’re not even limited to properties of the type, as shown below.