473,320 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
Feb 23 '06 #1
0 909

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ian Tompsett | last post by:
H I was wondering if it possible for an object to serialize/deserialize itself from XML. I'd be guessing that it would need to use the XmlSerializer class, but that seems to want to create a...
0
by: Mark | last post by:
Hi all, i'm trying to serialize a class. Using the constructor of XmlSerializer i get these (odd?) errors: "File or assembly name goseij9w.dll, or one of its dependencies, was not found"....
1
by: Kristian Kjems | last post by:
Look at the Code Snippet below: It is not possible to Deserialize the Animal in animalStr directly because the type of the animal is not known. Deserializing into the abstract type will not work...
1
by: Keith Harris | last post by:
Hi, I have a simple class named DistributionSelections which stores two enums and a dataset. I want to persist the object to a database for later retrieval. HERE IS THE CODE USED TO PERSIST...
5
by: Matthew | last post by:
I have a nice little Sub that saves data in a class "mySettings" to an XML file. I call it like so: Dim mySettings As mySettings = New mySettings mySettings.value1 = "someText" mySettings.value2...
0
by: Matt S | last post by:
Hello, I'm trying to build a C# client to consume an AXIS Web Service (running SOAP over HTTP). The Web Service encodes full server-side exception traces in the Soap Fault > Detail element...
5
by: DBC User | last post by:
Hi All, I am trying to presist an object in database. So I was searching and found the one (at the bottom of the message) in the groups and I followed it and it did create and store the data....
2
by: Thomas S | last post by:
Any suggestions on how to deserialize an object from one line of XML? I'm trying to deserialize multiple objects from one XML document, each object on one line of the file. The serialization is...
2
by: Frank | last post by:
Hi All, I've been yanking my hair out all day over this one, and finally decided to grab some sample code from MSDN, only to find the exact same problem What's the problem? The problem is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.