Deserializing object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Søren M. Olesen

    #1

    Deserializing object


    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


  • Spam Catcher

    #2
    Re: Deserializing object

    "Søren M. Olesen" <smolesen@hotma il.comwrote in
    news:u12bD4C2GH A.1040@TK2MSFTN GP06.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 ?

    Comment

    • tommaso.gastaldi@uniroma1.it

      #3
      Re: Deserializing object

      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 HasBeenNormally Instantiated As Boolean =
      True

      'Other properties ...

      End Class

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


      TIA

      Søren

      Comment

      • Tom Shelton

        #4
        Re: Deserializing object


        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 SerializationIn fo, ByVal context As
        StreamingContex t)

        This constructor will be called when the object is deserialized.

        --
        Tom Shelton

        Comment

        • Søren M. Olesen

          #5
          Re: Deserializing object

          Thanks a lot for all your replies, they have been very helpfull!!




          "Søren M. Olesen" <smolesen@hotma il.comwrote in message
          news:u12bD4C2GH A.1040@TK2MSFTN GP06.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
          >

          Comment

          Working...