V
V
Vitaly Pukhov2015-07-16 07:07:43
Programming
Vitaly Pukhov, 2015-07-16 07:07:43

Is partial deserialization possible?

In one of the applications, I serialize structures that, among other things, contain fairly large byte[] arrays (the total volume can reach gigabytes), the question arose whether it is possible to deserialize the structure not completely, without these arrays, but with the ability to load them as needs from disk?
So far, the only solution is to sequentially write arrays to a separate file, and store only the "array start" point and length in the structure, but this does not seem to be very convenient.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vvovas, 2015-07-16
@vvovas

It all depends on what you are serializing.
At the very least, xmlSerializer has an xmlignore attribute that can be applied to a class property and that property will not be deserialized.
To read the data later, you can create another class with a single property corresponding to an array, and deserialize this object.
something like:

class FullIObject{
    //some properties
   
    [XmlIgnore]
    public byte[] Data{get;set;}
}

class DataArray{
    public byte[] Data{get;set;}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question