public static string ToYaml(AampFile aampFile) { StringBuilder sb = new StringBuilder(); using (TextWriter writer = new StringWriter(sb)) { writer.WriteLine($"aamp_version: {aampFile.Version}"); writer.WriteLine($"io_version: {aampFile.ParameterIOVersion}"); writer.WriteLine($"type: {aampFile.ParameterIOType}"); WriteParamList(writer, aampFile.RootNode, 0); } return(sb.ToString()); }
public static AampFile LoadFile(Stream Stream) { AampFile file = null; uint version = CheckVersion(Stream); if (version == 2) { file = new AampFileV2(Stream); } else { file = new AampFileV1(Stream); } return(file); }
public static AampFile FromYaml(string text) { AampFile file = new AampFile(); var yaml = new YamlStream(); yaml.Load(new StringReader(text)); var mapping = (YamlMappingNode)yaml.Documents[0].RootNode; foreach (var entry in mapping.Children) { var key = ((YamlScalarNode)entry.Key).Value; var value = entry.Value.ToString(); if (key == "aamp_version") { file.Version = (uint)ParseValueInt(value); if (file.Version == 2) { file = new AampFileV2(); } else { file = new AampFileV1(); } } if (key == "type") { file.ParameterIOType = value; } if (entry.Value.Tag == "!list") { file.RootNode = ParseParamList(key, (YamlMappingNode)entry.Value); } } return(file); }
internal string ToJson(AampFile aampFile) { return(JsonConvert.SerializeObject(aampFile, Formatting.Indented)); }