Exemplo n.º 1
0
 public YmlEntry Parse(Stream stream)
 {
     var root = new YmlEntry("root");
     ICollection<YmlEntry> categories = root.Values;
     IEnumerable<string> rows = ReadAllRows(stream);
     YmlEntry parent = null;
     foreach (string row in rows)
     {
         if (row.StartsWith("\""))
         {
             string name = row.Substring(1, row.IndexOf("\"", 1) - 1);
             parent = new YmlEntry(name);
             categories.Add(parent);
         }
         else if (row.StartsWith("  "))
         {
             var nameValue = row.Trim().Split(':');
             var entry = new YmlEntry(nameValue[0]);
             var values = nameValue[1].Split('|');
             foreach (var value in values)
                 entry.AddValue(value.Trim());
             parent.Values.Add(entry);
         }
     }
     return root;
 }
Exemplo n.º 2
0
 private void Because_of()
 {
     var ms = new MemoryStream();
     var sr = new StreamWriter(ms);
     sr.WriteLine("# comment");
     sr.WriteLine("\"se\":");
     sr.WriteLine("# comment");
     sr.WriteLine("  example: Exempel");
     sr.WriteLine("  feature: Story|Krav|Feature");
     sr.Flush();
     ms.Seek(0, SeekOrigin.Begin);
     _parsedYmlRoot = _ymlParser.Parse(ms);
 }
Exemplo n.º 3
0
 private void LoadLanguages()
 {
     using (var r = GetType().Assembly.GetManifestResourceStream(GetType().Assembly.GetName().Name + ".i18n.yml"))
     {
         var ymlParser = new YmlParser();
         languages = ymlParser.Parse(r);
     }
 }