Interface Serializers
General
Serializing the interfaces entire class
Creating the writer
Example
public static void WriteISomething(this Writer writer, ISomething som)
{
if(som is ClassA c1)
{
// 1 will be the identifer for the reader that this is a ClassA.
writer.WriteByte(1);
writer.Write(c1);
}
else if(som is ClassB c2)
{
// 2 will be the identifier for the reader that this is a ClassB.
writer.WriteByte(2)
writer.Write(c2);
}
} Creating the reader
Example
Serializing only the interfaces properties
Creating the writer
Example
Creating the reader
example
Last updated