Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
There are two serialization methods on a business object: SerializeToStream and SerialzieToByteArray. These work just as the names state. SerializeToStream supports any stream type such as a network stream, file stream, memory stream, etc. Here is a sample of serializing a business object and then de-serializing it. I am using a file stream here for sample purposes, but you could just as easily use a network stream which could be remoted or allow you to create a server that hands out business objects. The possibilities are limitless.
Serialize the Business Object
Private Sub SerializeMethod()
'-- Establish Locals
Dim loFile As New System.IO.FileStream("c:\serializedBO.bin", System.IO.FileMode.Create)
Dim loCustomers As New CustomersBO()
'-- Load some data into the business object
loCustomers.FillAll()
'-- Serialize the business object to the stream
loCustomers.SerializeToStream(loFile)
'-- Close the stream
loFile.Close()
'-- Close the BO
loCustomers.Dispose()
End Sub
De-serialize the Business Object
Private Sub DeserializeMethod()
'-- Establish Lcoals
Dim loFile As New System.IO.FileStream("c:\serializedBO.bin", System.IO.FileMode.Open)
Dim loCustomers As CustomersBO
'-- Deserialize the saved business object from a stream
loCustomers = CustomersBO.DeserializeBusinessObject(loFile)
'-- Close the stream
loFile.Close()
End Sub
|