Click here to Skip to main content
15,921,028 members
Home / Discussions / C#
   

C#

 
QuestionXML: Deserialize but don't Serialize Pin
Clive Pottinger6-Nov-06 5:58
Clive Pottinger6-Nov-06 5:58 
AnswerRe: XML: Deserialize but don't Serialize Pin
led mike6-Nov-06 9:21
led mike6-Nov-06 9:21 
AnswerRe: XML: Deserialize but don't Serialize Pin
beatles16927-Nov-06 0:28
beatles16927-Nov-06 0:28 
GeneralRe: XML: Deserialize but don't Serialize Pin
Clive Pottinger8-Nov-06 14:52
Clive Pottinger8-Nov-06 14:52 
GeneralRe: XML: Deserialize but don't Serialize Pin
Clive Pottinger8-Nov-06 16:54
Clive Pottinger8-Nov-06 16:54 
QuestionXML Deserialization question Pin
Clive Pottinger6-Nov-06 5:49
Clive Pottinger6-Nov-06 5:49 
AnswerRe: XML Deserialization question Pin
S. Senthil Kumar6-Nov-06 6:41
S. Senthil Kumar6-Nov-06 6:41 
GeneralRe: XML Deserialization question [modified] Pin
Clive Pottinger6-Nov-06 7:25
Clive Pottinger6-Nov-06 7:25 
That is the essence of the problem - I don't see a way to do it.
I'll try adding some code - I'm away from my development environment at the moment, and doing this from memory, so don't laugh too hard at my syntax errors... (I'm sensitive)

<br />
public class Teacher{<br />
 private ArrayList ClassList = new ArrayList();<br />
 private ArrayList StudentList = new ArrayList();<br />
 [XMLAttribute("name");<br />
 public string Name;<br />
 [XMLElement("class")]<br />
 public Class[] AddClasses {  // Note: this will not be called until after all Class objects <br />
                              //       have been deserialised<br />
  get {return new Class[0];} // ignore serialising for now<br />
  set {<br />
    foreach( Class newClass in (Class[])value) {<br />
      newClass.teacher = this.Name};  // Hydrodynamics 101 now knows it is taught by Johnson<br />
      this.ClassList.Add(newClass);   // Johnson now knows that he/she is instructing Hydrodynamics 101 <br />
    }<br />
  }<br />
}<br />
<br />
public class Class {<br />
 [XMLAttribute("name")<br />
 public string Name;<br />
<br />
 [XMLIgnore]<br />
 public string teacher; // set by Johnson when Hydrodynamics 101 is added to the Johnson's list of classes<br />
 [XMLElement("student")]<br />
 public Student[] AddStudent {  // Note: this will not be called until after all Student objects have<br />
                                //       been deserialised<br />
  get {return new Student[0];} // ignore serialisation for now<br />
  set {<br />
    foreach( Student newStudent in (Student[]value) {<br />
      newStudent.ClassesToGoTo = this.Name;  // Billy now knows he is attending Hydrodynamics<br />
      newStudent.MyInstructors = ?  // **** How do I find the Teacher? Class["Hydrodynamics 101"].Teacher<br />
                                    //      is null because Class["Hydrodynamics 101"].AddClasses has <br />
                                    //      not been called yet because we aren't done deserialising all<br />
                                    //      the students within the element (namely billy).<br />
                                    //      Additionally, Teacher["Johnson"].ClassList is empty for the<br />
                                    //      same reason.<br />
    }<br />
  }<br />
}<br />
<br />
public class Student{<br />
 [XMLAttribute("name");<br />
 public string Name;<br />
 private ArrayList ClassesToGoTo = new ArrayList();<br />
 private ArrayList MyInstructors = new ArrayList();<br />
}<br />
<\code><br />
<br />
I know it's not complete, but hopefully it will illustrate my dilemma. <br />
<br />
<br />
 -- modified at 13:39 Monday 6th November, 2006 <br />
<br />
<div class="ForumSig">Clive Pottinger,<br />
Hamilton ON</div>

AnswerRe: XML Deserialization question Pin
Clive Pottinger6-Nov-06 7:52
Clive Pottinger6-Nov-06 7:52 
GeneralRe: XML Deserialization question Pin
S. Senthil Kumar7-Nov-06 5:30
S. Senthil Kumar7-Nov-06 5:30 
AnswerRe: XML Deserialization question Pin
Clive Pottinger8-Nov-06 15:10
Clive Pottinger8-Nov-06 15:10 
QuestionNearest neighbour algorithm Pin
Islam Khalil Saber6-Nov-06 4:35
Islam Khalil Saber6-Nov-06 4:35 
AnswerRe: Nearest neighbour algorithm Pin
J4amieC6-Nov-06 4:42
J4amieC6-Nov-06 4:42 
AnswerCross posting Pin
leckey6-Nov-06 6:41
leckey6-Nov-06 6:41 
Questiondatagridview help needed Pin
giddy_guitarist6-Nov-06 4:34
giddy_guitarist6-Nov-06 4:34 
AnswerRe: datagridview help needed Pin
Rey99997-Nov-06 6:36
Rey99997-Nov-06 6:36 
GeneralRe: datagridview help needed Pin
giddy_guitarist7-Nov-06 21:59
giddy_guitarist7-Nov-06 21:59 
QuestionTesting the presence of a reference Pin
Maercu6-Nov-06 4:23
Maercu6-Nov-06 4:23 
AnswerRe: Testing the presence of a reference Pin
led mike6-Nov-06 5:08
led mike6-Nov-06 5:08 
AnswerRe: Testing the presence of a reference Pin
liRetro6-Nov-06 5:51
liRetro6-Nov-06 5:51 
AnswerRe: Testing the presence of a reference Pin
Maercu6-Nov-06 21:46
Maercu6-Nov-06 21:46 
QuestionWhich class I should use in communication? Pin
mertkan656-Nov-06 4:11
mertkan656-Nov-06 4:11 
QuestionWeird problem... [modified] Pin
Support1236-Nov-06 3:52
Support1236-Nov-06 3:52 
AnswerRe: Weird problem... Pin
ednrgc6-Nov-06 4:09
ednrgc6-Nov-06 4:09 
GeneralRe: Weird problem... Pin
Support1236-Nov-06 4:34
Support1236-Nov-06 4:34 

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.