Home All Groups Group Topic Archive Search About

How to Deserialize to a specific object instance.

Author
15 Feb 2005 2:19 PM
MP
Hi,
    I would like to be able to deserialize a stream to a specific instance.
Deserialize returns me a new instances and that is not really what we need,
we need to deserialized to an existing instance. Can anyone point me in the
rigth direction?


Regards

-Martin
Author
15 Feb 2005 3:24 PM
Ollie Riches
when deserialize(re-hydrate) an object from an XML stream it creates a new
instance of the type so therefore it will have a completely different hash
code (GetHashCode()). If you want to map this onto an already existing
instance of the type you will have to do this after the deserialization has
been compeleted.

HTH


Ollie Riches
Show quoteHide quote
"MP" <martin.pare@I_Will_Not_Give_You_My_Address> wrote in message
news:ucl20l2EFHA.1932@TK2MSFTNGP14.phx.gbl...
> Hi,
>     I would like to be able to deserialize a stream to a specific
instance.
> Deserialize returns me a new instances and that is not really what we
need,
> we need to deserialized to an existing instance. Can anyone point me in
the
> rigth direction?
>
>
> Regards
>
> -Martin
>
>
Are all your drivers up to date? click for free checkup

Author
15 Feb 2005 3:47 PM
MP
Thank you Ollie,
    Then the obvious question is: Is there a simple way map one instance of
an object onto another? Kind of a copy operator....

Thank you again.

-Martin

Show quoteHide quote
"Ollie Riches" <ollie_ric***@hotmail.com> wrote in message
news:Ou$mCK3EFHA.4004@tk2msftngp13.phx.gbl...
> when deserialize(re-hydrate) an object from an XML stream it creates a new
> instance of the type so therefore it will have a completely different hash
> code (GetHashCode()). If you want to map this onto an already existing
> instance of the type you will have to do this after the deserialization
> has
> been compeleted.
>
> HTH
>
>
> Ollie Riches
> "MP" <martin.pare@I_Will_Not_Give_You_My_Address> wrote in message
> news:ucl20l2EFHA.1932@TK2MSFTNGP14.phx.gbl...
>> Hi,
>>     I would like to be able to deserialize a stream to a specific
> instance.
>> Deserialize returns me a new instances and that is not really what we
> need,
>> we need to deserialized to an existing instance. Can anyone point me in
> the
>> rigth direction?
>>
>>
>> Regards
>>
>> -Martin
>>
>>
>
>
Author
15 Feb 2005 3:57 PM
Ollie Riches
MS have created an interface in the .Net framework called 'ICloneable' that
is a pattern for copying an instance of  a class and returing the new
instance.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemicloneableclasstopic.asp

HTH

Ollie Riches

All you have to do is impletm "MP"
<martin.pare@I_Will_Not_Give_You_My_Address> wrote in message
Show quoteHide quote
news:#OfUmW3EFHA.2824@tk2msftngp13.phx.gbl...
> Thank you Ollie,
>     Then the obvious question is: Is there a simple way map one instance
of
> an object onto another? Kind of a copy operator....
>
> Thank you again.
>
> -Martin
>
> "Ollie Riches" <ollie_ric***@hotmail.com> wrote in message
> news:Ou$mCK3EFHA.4004@tk2msftngp13.phx.gbl...
> > when deserialize(re-hydrate) an object from an XML stream it creates a
new
> > instance of the type so therefore it will have a completely different
hash
> > code (GetHashCode()). If you want to map this onto an already existing
> > instance of the type you will have to do this after the deserialization
> > has
> > been compeleted.
> >
> > HTH
> >
> >
> > Ollie Riches
> > "MP" <martin.pare@I_Will_Not_Give_You_My_Address> wrote in message
> > news:ucl20l2EFHA.1932@TK2MSFTNGP14.phx.gbl...
> >> Hi,
> >>     I would like to be able to deserialize a stream to a specific
> > instance.
> >> Deserialize returns me a new instances and that is not really what we
> > need,
> >> we need to deserialized to an existing instance. Can anyone point me in
> > the
> >> rigth direction?
> >>
> >>
> >> Regards
> >>
> >> -Martin
> >>
> >>
> >
> >
>
>
Author
15 Feb 2005 3:30 PM
Peter Rilling
Why would you need it to be the same "instance"?

Show quoteHide quote
"MP" <martin.pare@I_Will_Not_Give_You_My_Address> wrote in message
news:ucl20l2EFHA.1932@TK2MSFTNGP14.phx.gbl...
> Hi,
>     I would like to be able to deserialize a stream to a specific
instance.
> Deserialize returns me a new instances and that is not really what we
need,
> we need to deserialized to an existing instance. Can anyone point me in
the
> rigth direction?
>
>
> Regards
>
> -Martin
>
>
Author
16 Feb 2005 9:54 AM
daiyue
I believe it's impossible to do so.
Show quoteHide quote
"MP" <martin.pare@I_Will_Not_Give_You_My_Address> дÈëÏûÏ¢ÐÂÎÅ:ucl20l2EFHA.1***@TK2MSFTNGP14.phx.gbl...
> Hi,
>    I would like to be able to deserialize a stream to a specific instance.
> Deserialize returns me a new instances and that is not really what we
> need, we need to deserialized to an existing instance. Can anyone point me
> in the rigth direction?
>
>
> Regards
>
> -Martin
>
Author
17 Feb 2005 1:30 PM
MP
Well.... I just figured it out. Now, I just need to get this working with
remoting.

-Martin
Show quoteHide quote
"daiyue" <myron***@gmail.com> wrote in message
news:OQWX%231AFFHA.3940@tk2msftngp13.phx.gbl...
>I believe it's impossible to do so.
> "MP" <martin.pare@I_Will_Not_Give_You_My_Address>
> дÈëÏûÏ¢ÐÂÎÅ:ucl20l2EFHA.1***@TK2MSFTNGP14.phx.gbl...
>> Hi,
>>    I would like to be able to deserialize a stream to a specific
>> instance. Deserialize returns me a new instances and that is not really
>> what we need, we need to deserialized to an existing instance. Can anyone
>> point me in the rigth direction?
>>
>>
>> Regards
>>
>> -Martin
>>
>
>
Author
29 Mar 2005 9:45 PM
John R.
MP,

How did you do it?  I need to do the same thing.

Thanks,

John

---------------
Show quoteHide quote
"MP" wrote:

> Well.... I just figured it out. Now, I just need to get this working with
> remoting.
>
> -Martin
> "daiyue" <myron***@gmail.com> wrote in message
> news:OQWX%231AFFHA.3940@tk2msftngp13.phx.gbl...
> >I believe it's impossible to do so.
> > "MP" <martin.pare@I_Will_Not_Give_You_My_Address>
> > дÈëÏûÏ¢ÐÂÎÅ:ucl20l2EFHA.1***@TK2MSFTNGP14.phx.gbl...
> >> Hi,
> >>    I would like to be able to deserialize a stream to a specific
> >> instance. Deserialize returns me a new instances and that is not really
> >> what we need, we need to deserialized to an existing instance. Can anyone
> >> point me in the rigth direction?
> >>
> >>
> >> Regards
> >>
> >> -Martin
> >>
> >
> >
>
>
>

Bookmark and Share