/// <summary> /// Pass in YAML in the form of a string and return a ParseResult with one or more Actions deserialized. /// </summary> /// <param name="yaml"></param> /// <returns></returns> public ParseResult Parse(string yaml) { ParseResult result = new ParseResult(); if (string.IsNullOrWhiteSpace(yaml)) { Exception e = new Exception("Empty or null YAML string."); result.CatchError(e); } else { yaml = ParsingHelper.CleanseYaml(yaml); StringReader input = new StringReader(yaml); var deserializer = new DeserializerBuilder() .WithNamingConvention(new CamelCaseNamingConvention()) .Build(); var parser = new Parser(input); parser.Expect <StreamStart>(); while (parser.Accept <DocumentStart>()) { try { var doc = deserializer.Deserialize <Action>(parser); doc.YamlArtifactID = -1; result.Library.Actions.Add(doc); } catch (Exception e) { if (e.InnerException != null) { if (e.InnerException.Message.Contains("not found")) { result.CatchError(Constants.ParseErrors.YamlParsingErrorInvalidTypeName, Constants.ParseErrors.YamlParsingErrorInvalidTypeComment, e); } } else { result.CatchError(e); } } } } return(result); }