title: YamlDotNet deserialization of deeply nested dynamic structures
body: <p>I have a deeply nested object model:</p>
  
  <pre><code>public class CheatSheet {
      public string Leader { get; set; }
      public List&lt;Section&gt; Sections { get; set; }
  }
  
  public class Section {
      public string Title { get; set; }
      public List&lt;SubSection&gt; SubSections { get; set; }
  }
  
  public class SubSection {
      public string Title { get; set; }
      public List&lt;Cheat&gt; Cheats { get; set; }
  }
  
  public class Cheat {
      public string Affected { get; set; }
      public string Text { get; set; }
      public string Hint { get; set; }
      public string Url { get; set; }
  }
  </code></pre>
  
  <p>And I have serialized this to YAML without any problems:</p>
  
  <pre><code>var serializer = new YamlDotNet.Serialization.Serializer();
  var sb = new StringBuilder();
  var sw = new StringWriter(sb);
  serializer.Serialize(sw, model);
  string yaml = sb.ToString();
  </code></pre>
  
  <p>The yaml looks good, very similar to a JSON or HJSON representation.</p>
  
  <p>I now want to deserialize it - n.b. I want to deserialize it into
  a dynamic object NOT into the original model (which is only being
  used in this example to generate the YAML in the first place, it
  won't exist in the final assembly).</p>
  
  <pre><code>var sr = new StringReader(yaml);
  var deserializer = new YamlDotNet.Serialization.Deserializer();
  dynamic expando = deserializer.Deserialize&lt;ExpandoObject&gt;(sr);
  </code></pre>
  
  <p>The problem is that the resulting expando is very difficult to use,
  containing many unnecessary levels of nesting. For example:</p>
  
  <pre><code>expando.Sections[0]["Title"]
  expando.Sections[0]["SubSections"][0]["Title"]
  expando.Sections[0]["SubSections"][0]["Cheats"][0]["Text"]
  </code></pre>
  
  <p>But I would like this to be</p>
  
  <pre><code>expando.Sections[0].Title
  expando.Sections[0].SubSections[0].Title
  expando.Sections[0].SubSections[0].Cheats[0].Text
  </code></pre>
  
  <p>Is this possible in any way?</p>
  
  <p>There is a repro program available at <a href="https://github.com/PhilipDaniels/Lithogen" rel="nofollow">https://github.com/PhilipDaniels/Lithogen</a>
  in the project Gitcheatsheet.TestHarness, at commit 2db9a0491e8ab50bb07aee552ddec6697c4b8bfc</p>