コード例 #1
0
        private YAMLDocument parse()
        {
            YAMLDocument yamlDocument = null;
            YAMLElement  yamlElement  = null;

            foreach (string line in _lines)
            {
                if (yamlDocument != null)
                {
                    if (line.IndexOf(YAMLDocument.PROPERTY_SPLITTER) > -1 && yamlElement != null)
                    {
                        YAMLProperty property = new YAMLProperty(line);
                        yamlElement.AddProperty(property);
                    }

                    if (line.StartsWith(YAMLDocument.ELEMENT_MARKER))
                    {
                        if (yamlElement != null)
                        {
                            yamlDocument.AddElement(yamlElement.Clone());
                        }

                        yamlElement = new YAMLElement();

                        yamlElement.Name = yamlElement.GetElementLineValue(line);
                    }
                }

                if (line.StartsWith(YAMLDocument.DOCUMENT_MARKER))
                {
                    if (YAMLDocument.GetDocumentLineValue(line) == YAMLDocument.SCREEN_KEYWORD)
                    {
                        yamlDocument = new YAMLDocument();
                    }
                }
            }

            if (yamlElement != null)
            {
                yamlDocument.AddElement(yamlElement.Clone());
            }

            return(yamlDocument);
        }
コード例 #2
0
 public void AddProperty(YAMLProperty property)
 {
     _properties.Add(property);
 }