Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 23rd, 2006, 11:35 PM
Tim Greenfield
Guest
 
Posts: n/a
Default Accessing new object before XmlSerializer.Deserialize completes

Hello, the XmlSerializer class is great but it seems like it's lacking one
very important feature... the ability for the caller to access the newly
created object prior to finishing deserialization. What if you were
deserializing in xml but you needed access to a dependency in order to
perform the deserialization.

Here's an example of a class that needs to look up a resource based on the
ID it receives during deserialization but there's no way to set the
Resources property first.

Public Class Class1
Implements Xml.Serialization.IXmlSerializable

Public ResourceValue As Object
Public Resources As Hashtable ' this needs to be passed in before
ReadXml can be called

Public Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements
System.Xml.Serialization.IXmlSerializable.ReadXml
Dim ResourceId As String = reader.ReadElementString
ResourceValue = Resources(ResourceId)
End Sub

...etc...

End Class

XmlSerializer only supports passing in a type but not constructor args nor
does it raise a BeforeDeserialize(NewObject) event. Can anyone else confirm
that this is simply not possible? It seems like it would have been really
easy for MS to add support for this but just didn't.

-- Tim


 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles