Home All Groups Group Topic Archive Search About
Author
14 Sep 2006 6:45 PM
Søren M. Olesen
Hi

Is there any way (at all) that an object beign deserialized from a stream
can know (or figure out) that it has been created because of a deserialize
process rather than by a "normal" object instiantiation ??


TIA

Søren

Author
14 Sep 2006 7:20 PM
Spam Catcher
"Søren M. Olesen" <smole***@hotmail.com> wrote in
news:u12bD4C2GHA.1040@TK2MSFTNGP06.phx.gbl:

> Is there any way (at all) that an object beign deserialized from a
> stream can know (or figure out) that it has been created because of a
> deserialize process rather than by a "normal" object instiantiation ??
>

Maybe u can create a property "IsDeserialized" and flag the object during
deserialization?
Author
14 Sep 2006 9:38 PM
tommaso.gastaldi@uniroma1.it
Søren M. Olesen ha scritto:

> Hi
>
> Is there any way (at all) that an object beign deserialized from a stream
> can know (or figure out) that it has been created because of a deserialize
> process rather than by a "normal" object instiantiation ??

How about this :

<Serializable()> Class YourObject

    <nonserialized()> Public HasBeenNormallyInstantiated As Boolean =
True

    'Other properties ...

End Class

the flag HasBeenNormallyInstantiated will hold the answer because when
deserialized will be false. Will be true when YourObject "normally"
instantiated.

Show quoteHide quote
>
>
> TIA
>
> Søren
Author
14 Sep 2006 10:23 PM
Tom Shelton
Søren M. Olesen wrote:
> Hi
>
> Is there any way (at all) that an object beign deserialized from a stream
> can know (or figure out) that it has been created because of a deserialize
> process rather than by a "normal" object instiantiation ??
>
>
> TIA
>
> Søren

Well yes...  If you implement the ISerializable interface, then you
will have to add a constructor like:

Public Sub New (ByVal info As SerializationInfo, ByVal context As
StreamingContext)

This constructor will be called when the object is deserialized.

--
Tom Shelton
Author
15 Sep 2006 4:54 AM
Søren M. Olesen
Thanks a lot for all your replies, they have been very helpfull!!




Show quoteHide quote
"Søren M. Olesen" <smole***@hotmail.com> wrote in message
news:u12bD4C2GHA.1040@TK2MSFTNGP06.phx.gbl...
>
> Hi
>
> Is there any way (at all) that an object beign deserialized from a stream
> can know (or figure out) that it has been created because of a deserialize
> process rather than by a "normal" object instiantiation ??
>
>
> TIA
>
> Søren
>