Monday, March 26, 2012

Serializable()

<Serializable()Public Class Dealer

What does Serializable do?

Regards /SnedkerIt allows another object to convert your object's properties into a form
that can be transmitted, saved etc and then re-created. As an object is
basically a bunch of binary data you can't do much with it beyond your
existing app.

Marking your object as serialisable means it can be stored in the viewstate,
stored in the session if you're not using in-proc sessions, can be sent via
remoting, web methods etc. What happens is that the object's data is stored
in a property bag type thing, that property bag is saved somewhere
(viewstate, session etc) or sent (remoting etc) then the receiving code will
deserialise the object by creating a new instance of one and setting its
properties as dictated by the property bag. So in psuedo code;

//Take object's property values and store in the viewstate
ViewState ["myObject"] = myObject;

// Create new instance of object, read the property values are read from the
viewstate
// and populate the new object with them
myObject = (MyObjectType) ViewState["myObject"];

The two objects *look* the same as they have the same property values, but
they are not the actual same binary object.

"Morten Snedker" <morten.snedker@.gmail.comwrote in message
news:%23Nft5JG8HHA.5796@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

<Serializable()Public Class Dealer
>
What does Serializable do?
>
>
>
>
Regards /Snedker
>


thats what serialization does.

setting the Serializable attribute means the object will successfully
serialize if asked to. either the object implements ISerializable or
follows all the rules for the default serialization logic to work.

-- bruce (sqlwork.com)

Aidy wrote:

Quote:

Originally Posted by

It allows another object to convert your object's properties into a form
that can be transmitted, saved etc and then re-created. As an object is
basically a bunch of binary data you can't do much with it beyond your
existing app.
>
Marking your object as serialisable means it can be stored in the viewstate,
stored in the session if you're not using in-proc sessions, can be sent via
remoting, web methods etc. What happens is that the object's data is stored
in a property bag type thing, that property bag is saved somewhere
(viewstate, session etc) or sent (remoting etc) then the receiving code will
deserialise the object by creating a new instance of one and setting its
properties as dictated by the property bag. So in psuedo code;
>
//Take object's property values and store in the viewstate
ViewState ["myObject"] = myObject;
>
// Create new instance of object, read the property values are read from the
viewstate
// and populate the new object with them
myObject = (MyObjectType) ViewState["myObject"];
>
The two objects *look* the same as they have the same property values, but
they are not the actual same binary object.
>
"Morten Snedker" <morten.snedker@.gmail.comwrote in message
news:%23Nft5JG8HHA.5796@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

><Serializable()Public Class Dealer
>>
>What does Serializable do?
>>
>>
>>
>>
>Regards /Snedker
>>


>
>

0 comments:

Post a Comment