|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to Deserialize to a specific object instance.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 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 > > 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 >> >> > > 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 > >> > >> > > > > > > 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 > > 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 > 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 >> > > 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 > >> > > > > > > >
Other interesting topics
How to assign value to Excel 2000 worksheet cell
Simple: Excel Jet 4.0 Link vb 2005 RE: For vs. For Each Method for finding dotnet version How does IIS or Framework set the Content-Length header ? .net and mysql join ENTER and forms Excel process doesn't shut down VS 2002 and Framework 1.0/1.1 SP upgrades xcel error at web server |
|||||||||||||||||||||||