Lets say I have some data
1: {
1: 0.0
2: 1
3: "2"
4: true
}
But at compile time I don't know the contract. At run-time however, I can load a data descriptor that tells me how many fields I have and what each type in each field will be. i.e.
new Type[]{
typeof(double),
typeof(int),
typeof(string),
typeof(bool)};
Q: How can I, at run-time, get protocol-buf to read (and write) the message from a stream given the data-description?
My current thinking is this: Create a type at run-time (emit) given the data description then have protocol-buf serialise/deserialise with that. Then access properties via reflection/dynamic. Not sure if this is a good idea though.
This is an alternative approach from Serialize object[] with Protobuf-net