I did a quick search about the usage of oneof
in Protobuf-net
and it appears it's supported as of v2.3.0, but I can't for the life of me find any examples on exactly how one would use it!
My requirements are pretty simple, and maybe this can also be solved with [ProtoInclude]
but I'm not quite sure exactly how this would work. I've got the following class:
[ProtoContract]
public class ProgressUIMessage
{
[ProtoMember(1)]
public int Id {get; set;}
[ProtoMember(2)]
public object Message {get; set;}
}
Where Message
can be 1 of 8 different known types. The types do not inherit from each other at all and although the code can be changed, there's nothing all types have in common.
Using Google.Protobuf
I'd expect to do something similar to this, where I have a property called Instrument
that can be one of two types in the example above and then use InstrumentOneofCase
to figure out which type I was given. But how do I achieve the same thing in Protobuf-net
?
EDIT: I'll leave the original question as it, but perhaps a better question which more people can relate to is: how would you achieve the same thing as with this MS example in Protobuf-net? Both in terms of writing the class itself and in terms of determining what concrete type the parameter is in the end?