Haedrian
Haedrian

Reputation: 4328

Making a third-party struct serialisable

So basically I'm using a third party library which has a particular Struct which I need to serialise.

The actual struct is heavily used by other functions which I need, so I can't just rewrite it myself from scratch.

I can't extend the struct itself (because structs can't be extended) and the solution I found here won't really work for me as I'm using it in a ton of classes which I can't stay implementing serialisation manually for.

Anything I can do ?

Upvotes: 0

Views: 42

Answers (1)

vc 74
vc 74

Reputation: 38179

You can use a SerializationSurrogate to serialize instances of a type that was not designed for serialization.

Upvotes: 1

Related Questions