I have an object which
- does not have the Serializable attribute set
- Has properties, who's type, does not have the Serializable attribute set
- I do not have control over (meaning i cannot edit the class)
I tried reading THIS, it talks about substitution classes to fix this when using Sharpserializer but frankly, I don't understand how to do this when I don't know the properties of my object.
are there some of serialization frameworks that can do this?
Edit: I'm looking into protobuf.net I cannot figure out how to get it to work in my scenario though - Im hoping Marc will swing by to save the day? :) - I read this which is the exact same problem as mine, but I'm still getting "Type is not expected and no contract can be inferred" when using
private static byte[] ClienToBytes(IScsClient client)
{
using (var memoryStream = new MemoryStream())
{
RuntimeTypeModel.Default.Add(typeof(IScsClient), true).SetSurrogate(typeof(BinaryFormatterSurrogate<IScsClient>));
Serializer.Serialize(memoryStream, client);
return memoryStream.ToArray();
}
}
am I using the RunTimeTypeModel wrong?