Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since the object graph may be cyclic, you cannot possibly make a Tree-based structure out of it. Your best bet is to represent the object graph by it's simplest components: nodes and vectors. </p> <p>More specifically, make each node (object) an element with a unique ID (perhaps provided by C#'s GetHashCode() method?). References to other objects (vectors) would be handled by referencing the ID of the object.</p> <p>Example classes (note that I don't know C# so my syntax may be a bit off):</p> <pre><code>public class SomeType { public int myInt { get; set; } } public class AnotherType { public string myString { get; set; } public SomeType mySomeType { get; set; } } public class LastType { public SomeType mySomeType { get; set; } public AnotherType myAnotherType { get; set; } } public class UserTypes{ static void Main() { LastType lt = new LastType(); SomeType st = new SomeType(); AnotherType atype = new AnotherType(); st.myInt = 7; atype.myString = "BOB"; atype.mySomeType = st; lt.mySomeType = st; lt.myAnotherType = atype; string xmlOutput = YourAwesomeFunction(lt); } } </code></pre> <p>Then we would expect the value of xmlOutput to be something like this (note that the ID values chosen are completely synthetic):</p> <pre><code>&lt;ObjectMap&gt; &lt;LastType id="0"&gt; &lt;mySomeType idref="1" /&gt; &lt;myAnotherType idref="2" /&gt; &lt;/LastType&gt; &lt;SomeType id="1"&gt; &lt;myInt&gt;7&lt;/myInt&gt; &lt;/SomeType&gt; &lt;AnotherType id="2"&gt; &lt;myString&gt;BOB&lt;/myString&gt; &lt;mySomeType idref="1" /&gt; &lt;/AnotherType&gt; &lt;/ObjectMap&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload