Click here to Skip to main content
15,902,299 members
Home / Discussions / C#
   

C#

 
QuestionWhat the heck does this mean? [modified] Pin
Nathan Revka2-Aug-09 10:56
Nathan Revka2-Aug-09 10:56 
AnswerRe: What the heck does this mean? Pin
Richard Andrew x642-Aug-09 11:07
professionalRichard Andrew x642-Aug-09 11:07 
AnswerRe: What the heck does this mean? Pin
Christian Graus2-Aug-09 11:38
protectorChristian Graus2-Aug-09 11:38 
QuestionAdvice Pin
michael_jhons2-Aug-09 8:16
michael_jhons2-Aug-09 8:16 
AnswerRe: Advice Pin
Manas Bhardwaj2-Aug-09 9:04
professionalManas Bhardwaj2-Aug-09 9:04 
QuestionDeserialising derived classes using XmlAttributeOverrides Pin
Clive D. Pottinger2-Aug-09 6:39
Clive D. Pottinger2-Aug-09 6:39 
AnswerRe: Deserialising derived classes using XmlAttributeOverrides Pin
N a v a n e e t h2-Aug-09 7:55
N a v a n e e t h2-Aug-09 7:55 
GeneralRe: Deserialising derived classes using XmlAttributeOverrides Pin
Clive D. Pottinger3-Aug-09 6:08
Clive D. Pottinger3-Aug-09 6:08 
Thanks Navaneeth.

To answer point about where the XmlSerializer was getting my XmlAttributesOverrides object: the idea was to have the Orchestra class deserialise each <bloweythingy> and <hittythingy> tag as it encountered them. To do this Orchestra implement IXmlSerializable and the deserialisation was done inside the ReadXml() method. So the XmlAttributeOverrides were being assigned to the XmlSerializer ts in the Orchestra class, not the iniSerializer in Main.

That was the idea.

But after carefully examining the example you linked to, I now realise my mistake: I misunderstood the meaning of each parameter in the XmlAttributeOverrides.Add() method. I had written
instrumentXmlOverrides.Add(typeof(Instrument), kvp.Value.Name, xa);
<small>= when told to deserialise an Instrument [parm 1], if you run across a <bloweythingy> tag [parm2] apply the rules in xa (deserialise the <bloweythingy> tags into Woodwinds) [parm 3]</small>
I thought the first 2 parms were the class being deserialised and the "alternate" tagname for that class (Instrument and <bloweythingy>). In reality they are the class being deserialised and the tagname/class name of a property of that class. I should have been trying do this:
instrumentXmlOverrides.Add(typeof(Orchestra), "Instrument", xa);
<small>= when told to deserialise an Orchestra [parm 1], where you would normally expect an Instrument tag [parm2] apply the rules in xa (which should include both alternate tagnames for Instrument [bloweythingy and hittythingy] and their classes [Woodwinds and Percussion]) [parm 3]</small>

In order to do that, I had to reorganise my code so that the overrides were all constructed before ever trying to deserialise Orchestra. That allowed me to remove the IXmlSerializable interface from Orchestra and simplify the code.

Thanks again, Navaneeth. I can now move ahead with the actual application I am writing.

Clive Pottinger
Victoria, BC

GeneralRe: Deserialising derived classes using XmlAttributeOverrides Pin
N a v a n e e t h3-Aug-09 16:27
N a v a n e e t h3-Aug-09 16:27 
AnswerRe: Deserialising derived classes using XmlAttributeOverrides Pin
Henry Minute2-Aug-09 9:09
Henry Minute2-Aug-09 9:09 
GeneralRe: Deserialising derived classes using XmlAttributeOverrides Pin
Clive D. Pottinger3-Aug-09 6:13
Clive D. Pottinger3-Aug-09 6:13 
QuestionAccessing the file of a T-SQL BACKUP call Pin
Uwe Keim2-Aug-09 6:00
sitebuilderUwe Keim2-Aug-09 6:00 
AnswerRe: Accessing the file of a T-SQL BACKUP call Pin
N a v a n e e t h2-Aug-09 7:40
N a v a n e e t h2-Aug-09 7:40 
GeneralRe: Accessing the file of a T-SQL BACKUP call Pin
Uwe Keim2-Aug-09 19:15
sitebuilderUwe Keim2-Aug-09 19:15 
AnswerRe: Accessing the file of a T-SQL BACKUP call Pin
Mycroft Holmes2-Aug-09 12:21
professionalMycroft Holmes2-Aug-09 12:21 
GeneralRe: Accessing the file of a T-SQL BACKUP call Pin
Uwe Keim2-Aug-09 19:15
sitebuilderUwe Keim2-Aug-09 19:15 
Questionnotify icon Pin
Vivek Vijayan2-Aug-09 2:18
Vivek Vijayan2-Aug-09 2:18 
AnswerRe: notify icon Pin
Manas Bhardwaj2-Aug-09 2:27
professionalManas Bhardwaj2-Aug-09 2:27 
GeneralRe: notify icon Pin
Abhijit Jana2-Aug-09 2:38
professionalAbhijit Jana2-Aug-09 2:38 
GeneralRe: notify icon Pin
Manas Bhardwaj2-Aug-09 2:39
professionalManas Bhardwaj2-Aug-09 2:39 
AnswerRe: notify icon Pin
CoderForEver2-Aug-09 8:06
CoderForEver2-Aug-09 8:06 
QuestionCustom user control Pin
Jon Henry2-Aug-09 1:45
Jon Henry2-Aug-09 1:45 
AnswerRe: Custom user control Pin
Super Lloyd2-Aug-09 2:38
Super Lloyd2-Aug-09 2:38 
GeneralRe: Custom user control Pin
Jon Henry2-Aug-09 2:46
Jon Henry2-Aug-09 2:46 
GeneralRe: Custom user control Pin
Super Lloyd2-Aug-09 2:54
Super Lloyd2-Aug-09 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.