Conditional Serialization in Protobuf

In this blog post, we will discuss how to conditionally serialize a property when using Protobuf Serialization. We are using the Protobuf-net library by Marc Gravell. I will attempt to use the same example class/scenario which I had previously used for Conditional Serialization in Json since it bears a lot of similarity. [ProtoContract] public class User { [ProtoMember(1)] public … Continue reading Conditional Serialization in Protobuf

Handling Cyclic References during Serialization

In the previous post, we discussed handling subtypes during protubuf serialization. In this post, we will continue with serialization and discuss the handling of cyclic references. We will look into how cyclic references could be addressed in 3 key types of serializations. JsonXmlProtobuf As an example of cyclic references, we will address the classic example … Continue reading Handling Cyclic References during Serialization

Protobuf – Handling sub-classes

In this blog post, we will look into how to handle subclasses or interface implementations during protobuf serialization. Consider the following class. [ProtoContract] public class Person { [ProtoMember(1)] public string FirstName { get; set; } [ProtoMember(2)] public string LastName { get; set; } } For serializing an instance of the above with protobuf-net, you could do … Continue reading Protobuf – Handling sub-classes

Quick Intro to Protobuf

Protobuf-net is a .net adaption of Google's Protocol Buffers and is generally considered to be a really fast serialization/deserialization library.  The target serializable classes are decorated with mainly 3 attributes. ProtoContract The target class is decorated with the ProtoContract attributes, indicating that the class can be serialized. ProtoMember(N) The ProtoMember attribute indicates the field that … Continue reading Quick Intro to Protobuf