c# - Save YamlStream from YamlDotNet Plugin to text file -


i need construct yaml configuration file ros node, inside c# application. basically, users specifies parameters values, , fetch values write yaml file.

i'm developing on monodevelop of great yamldotnet plugin @antoine aubry. however, starting question : build yaml document dynamically c#, cannot find way save yaml document simple text file, instead of outputting in console.

i've been looking streamwriter, textwriter, byte converter , many things i'm little lost here. i'm using example code, in fiddle https://dotnetfiddle.net/0raqgn

  var address = new yamlmappingnode(         new yamlscalarnode("street"), new yamlscalarnode("123 tornado alley\nsuite 16") { style = yamldotnet.core.scalarstyle.literal },         new yamlscalarnode("city"), new yamlscalarnode("east westville"),         new yamlscalarnode("state"), new yamlscalarnode("ks")     ) { anchor = "main-address" };    var stream = new yamlstream(         new yamldocument(             new yamlmappingnode(                 new yamlscalarnode("repeipt"), new yamlscalarnode("oz-ware purchase invoice"),                 new yamlscalarnode("date"), new yamlscalarnode("2007-08-06"),                 new yamlscalarnode("customer"), new yamlmappingnode(                     new yamlscalarnode("given"), new yamlscalarnode("dorothy"),                     new yamlscalarnode("family"), new yamlscalarnode("gale")                 ),                 new yamlscalarnode("items"), new yamlsequencenode(                     new yamlmappingnode(                         new yamlscalarnode("part_no"), new yamlscalarnode("a4786"),                         new yamlscalarnode("descrip"), new yamlscalarnode("water bucket (filled)"),                         new yamlscalarnode("price"), new yamlscalarnode("1.47"),                         new yamlscalarnode("quantity"), new yamlscalarnode("4")                     ),                     new yamlmappingnode(                         new yamlscalarnode("part_no"), new yamlscalarnode("e1628"),                         new yamlscalarnode("descrip"), new yamlscalarnode("high heeled \"ruby\" slippers"),                         new yamlscalarnode("price"), new yamlscalarnode("100.27"),                         new yamlscalarnode("quantity"), new yamlscalarnode("1")                     )                 ),                 new yamlscalarnode("bill-to"), address,                 new yamlscalarnode("ship-to"), address,                 new yamlscalarnode("specialdelivery"), new yamlscalarnode("follow yellow brick\nroad emerald city.\npay no attention the\nman behind curtain.") { style = yamldotnet.core.scalarstyle.literal }             )         )     ); 

the last thing tried :

streamwriter sw = new streamwriter (@"/home/guillaume/test_yaml.yaml"); stream.save (sw); 

but file test_yaml.yaml remains empty (0 octets) every damn time, whereas want :

  repeipt: oz-ware purchase invoice   date: 2007-08-06   customer:     given: dorothy     family: gale   items:   - part_no: a4786     descrip: water bucket (filled)     price: 1.47     quantity: 4   - part_no: e1628     descrip: high heeled "ruby" slippers     price: 100.27     quantity: 1   bill-to: &main-address     street: |-       123 tornado alley       suite 16     city: east westville     state: ks   ship-to: *main-address   specialdelivery: |-     follow yellow brick     road emerald city.     pay no attention     man behind curtain.   ... 

sorry if looks noob question!


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -