Created
July 26, 2015 08:14
-
-
Save apanda/9aa865a77db46f8192f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using YamlDotNet.Serialization; | |
using YamlDotNet.Serialization.NamingConventions; | |
namespace YamlDotNet.Samples | |
{ | |
public class DeserializeObjectGraph | |
{ | |
public void Main() | |
{ | |
var input = new StringReader(Doc2); | |
var deserializer = new Deserializer(namingConvention: new CamelCaseNamingConvention()); | |
deserializer.RegisterTagMapping("tag:yaml.org,2002:softnic", typeof(SoftNIC)); | |
deserializer.RegisterTagMapping("tag:yaml.org,2002:nf", typeof(NF)); | |
var order = deserializer.Deserialize<SN>(input); | |
} | |
public class CommandC { | |
} | |
public class SoftNIC : CommandC { | |
public SNArgs Argument {set; get;} | |
} | |
public class NF : CommandC { | |
public NFArgs Argument {set;get;} | |
} | |
public class SNArgs { | |
public List<String> Cores {set; get;} | |
} | |
public class NFArgs { | |
public int Nfid {get; set;} | |
public string Name {get; set;} | |
public List<string> Arguments {get;set;} | |
public List<int> Cores {get; set;} | |
} | |
public class SN { | |
public List<CommandC> Requests {get; set;} | |
} | |
private const string Doc2 = @"--- | |
requests: | |
- !!softnic | |
argument: | |
cores: [0] | |
- !!nf | |
argument: | |
nfid: 1 | |
name: firewall | |
arguments: [-e] | |
cores: [1] | |
..."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment