title: How to specify serialize custom type in YamlDotNet?
body: <p>Here is my simple class, where DigitalStorage is a binary serialiazable class. Its source code can be found here: </p>
  
  <p><a href="https://github.com/QualiSystems/Toscana/blob/master/Toscana/Domain/DigitalStorage.cs" rel="nofollow">https://github.com/QualiSystems/Toscana/blob/master/Toscana/Domain/DigitalStorage.cs</a></p>
  
  <pre><code>public class Host
  {
      public HostProperties Properties { get; set; }
  }
  
  public class HostProperties
  {
  
      [YamlAlias("mem_size")]
      public DigitalStorage MemSize { get; set; }
  }
  </code></pre>
  
  <p>When I try to deserialize the following YAML, it fails:</p>
  
  <pre><code>host:
      properties:
          mem_size: 4096 MB
  </code></pre>
  
  <p>Here is the exception:</p>
  
  <pre><code>YamlDotNet.Core.YamlException : (Line: 16, Col: 22, Idx: 396) - (Line: 16, Col: 29, Idx: 403): Exception during deserialization
  ----&gt; System.InvalidCastException : Invalid cast from 'System.String' to 'Toscana.Domain.DigitalStorage'.
  at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(EventReader reader, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer) in C:\projects\yamldotnet\YamlDotNet\Serialization\ValueDeserializers\NodeValueDeserializer.cs:line 75
  </code></pre>