Not in the main implementation - you would like to use encapsulation instead.
However, if you use only protobuf-net as the first code, I cheat on it:
[ProtoInclude(1, typeof(AddExpr))] [ProtoInclude(2, typeof(CallFunc))] [ProtoContract] class Expr {} [ProtoContract] class AddExpr : Expr {} [ProtoContract] class CallFunc: Expr {} [ProtoContract] class FunctionBody{ private List<Expr> expressions; [ProtoMember(1)] public List<Expr> Expressions { get { return expressions ?? (expressions = new List<Expr>()); } } }
Of course, I assume that there are additional details in the classes - βas isβ, you can simply use an enumeration (which is well supported).
Marc gravell
source share