Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Portable Class library object serialization

I am working on Xamarin iOS application. I also want to develop the same application for Android as well. So I am planning to write most of the code in a portable class library project.

The issue that I am facing now is, I cannot serialize the object of the class that created inside the “Portable class library” project. The “[Serializable]” attribute not supported inside the portable class library. I want to implement binary format serialization inside the portable class library project . How I achieve this.

Any help would ne appreciable.

like image 735
Ranish Avatar asked Oct 01 '22 10:10

Ranish


1 Answers

I would strongly suggest not using the built-in binary serialization even if you could... and it sounds like basically can't anyway. There are plenty of alternatives for serialization, depending on your requirements. You could consider:

  • JSON (e.g. with Json.NET)
  • Protocol Buffers
  • YAML
  • XML

These have different trade-off in terms of whether you need to make the data that you're serializing separate to your normal code or whether they can serialize "in-place", the readability, efficiency etc. But all are nice and portable, not just between .NET/Xamarin implementations but also other platforms.

like image 133
Jon Skeet Avatar answered Oct 07 '22 17:10

Jon Skeet