Author Topic: Object serialisation and storage in an XRECORD  (Read 2839 times)

0 Members and 1 Guest are viewing this topic.

cnicho

  • Guest
Object serialisation and storage in an XRECORD
« on: February 07, 2013, 10:58:07 AM »
Hi,
I'm saving an object in an extension dictionary. I've serialised it using binary serialisation then converted it to a Base64 string to make it easier to save in an XRECORD before saving it to the extension dictionary.

Is there any advantage in saving it in an XRECORD as binary data with all the necessary additional code to 'chunk' it?

Regards
Craig

AutoCAD 2013
.Net 4
C#
ObjectARX 2013
VS 2010 SP1

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Object serialisation and storage in an XRECORD
« Reply #1 on: February 07, 2013, 11:26:48 AM »
Depends what you are saving, but I'd have a hard time justifying it for most information.  Maybe for direct-coded images, digitized analog input, or other pure data.  If you get to the point where binary compression algorithms give reasonable compression of the stored data, then external storage would be far simpler to implement.

Not being able to directly inspect the values for even the simplest debugging.  There are so many string, integer/signed integer, double, coordinate, handles, and other storage types that using binary doesn't seem worth the bother.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

TheMaster

  • Guest
Re: Object serialisation and storage in an XRECORD
« Reply #2 on: February 07, 2013, 12:23:22 PM »
Hi,
I'm saving an object in an extension dictionary. I've serialised it using binary serialisation then converted it to a Base64 string to make it easier to save in an XRECORD before saving it to the extension dictionary.

Is there any advantage in saving it in an XRECORD as binary data with all the necessary additional code to 'chunk' it?

Regards
Craig

AutoCAD 2013
.Net 4
C#
ObjectARX 2013
VS 2010 SP1

You can store binary data directly without having to encode it, but the disadvantage of either binary or binary-encoded strings is that AutoCAD and your applications cannot recognize the data for what it actually is. For example, if you store ObjectIds in XRecords, AutoCAD recognizes them and translates them during deep clone operations. There may also be other situations where you want the data to be in a form that can be determined easily without having to decode it. Unless there is some security-related reasons for doing it, and the data is not binary data (like an image or what have you) that isn't supported by AutoCAD's standard protocol, I wouldn't effectively-encrypt data stored in DWG files.

cnicho

  • Guest
Re: Object serialisation and storage in an XRECORD
« Reply #3 on: February 07, 2013, 01:48:27 PM »
Hi
I did start by using XML serialisation of my objects which kept them readable but when my objects became more complex where they implement a hierarchy of objects, the XML serialisation failed.  The binary option enabled me to easily serialise/deserialise and to continue with the 'easy' option and continue storing it as text in the extension dictionary I converted the binary data to a Base64 string.

There's no technical issue with AutoCAD internally that would prevent me continuing with this until I've become more competent with XML serialisation that you're aware of?


TheMaster

  • Guest
Re: Object serialisation and storage in an XRECORD
« Reply #4 on: February 07, 2013, 07:51:46 PM »
Hi
I did start by using XML serialisation of my objects which kept them readable but when my objects became more complex where they implement a hierarchy of objects, the XML serialisation failed.  The binary option enabled me to easily serialise/deserialise and to continue with the 'easy' option and continue storing it as text in the extension dictionary I converted the binary data to a Base64 string.

There's no technical issue with AutoCAD internally that would prevent me continuing with this until I've become more competent with XML serialisation that you're aware of?

No, to AutoCAD, it's just undefined binary data that it treats as exactly that.