StrataFrame Forum

Serialization rocks.....

http://forum.strataframe.net/Topic2751.aspx

By Keith Chisarik - 9/12/2006

I hadn't fully wrapped my brain around it when I attended the training. Now I have and I LOVE it. I have serialized the contents of my custom classes, listbox contents, and BO's, mostly to XML for transport to other processes or applications. If your just coming into .NET like I was, get to know serialization, you wont regret it.



Mosty as a way to learn, I have written my own (De)SerializeToXML() classes. Now that I understand it, I have no issue with shortcuts. Does a SerializeToXML method for BO's exist in the framework?



Thanks.
By StrataFrame Team - 9/12/2006

The basic serialization methods on the BusinessLayer class use the BinaryFormatter instead of an XML formatter.  However, you can serialize just the data within the business object by accessing the DataTable.WriteXml() method on the CurrentDataTable property like this:

MyBO.CurrentDataTable.WriteXml(parameters...)

By Ivan George Borges - 9/12/2006

I'm really jealous right now.
By Keith Chisarik - 9/12/2006

Ivan George Borges (09/12/2006)
I'm really jealous right now.




Ben makes me jealous too.... someday I'll be there.



<< starts to sing poorly >>

If I could be like Ben......
By Ivan George Borges - 9/13/2006

Keith Chisarik (09/12/2006)

Ben makes me jealous too.... someday I'll be there.

Well, I'm not sure I will get to Ben's current level ... but if I do, I'm sure he will be already reading the binary code directly or something ...

Tried the serialization, think I got the idea. So, as an example, I had a field declared as System.Drawing.Bitmap in my table, to store a picture. So, that's why I had to tell the Business Object Mapper to "serialize" it, which means, convert the Object into a binary that could be saved into the sql binary field?

Then, this is what the BO Mapper is doing, letting me work with the field as a bitmap Object? And when it does it, it DEserialize it ?

By StrataFrame Team - 9/14/2006

Yep, Ivan.  A property is just a combination of two methods... one to "get" the value and one to "set" the value... So, when you get the value, the "get" method takes the binary data stored within the field and deserializes it (reconstructs the Bitmap object) and hands you the object as a System.Drawing.Bitmap.  When you set the value, the "set" method then takes the Bitmap object you passed and serializes it (create a binary stream from the object data) and stores that binary data in the binary field in the business object.
By Ivan George Borges - 9/14/2006

Got it Ben.

Thanks a lot!

By StrataFrame Team - 9/14/2006

No problem Smile