Esempio n. 1
0
        public void InsertBegin(string key, YAMLNode value)
        {
            YAMLScalarNode keyNode = new YAMLScalarNode();

            keyNode.Value = key;
            InsertBegin(keyNode, value);
        }
Esempio n. 2
0
        public void Add(string key, YAMLNode value)
        {
            YAMLScalarNode keyNode = new YAMLScalarNode();

            keyNode.Value = key;
            InsertEnd(keyNode, value);
        }
Esempio n. 3
0
 public YAMLDocument(YAMLNode root)
 {
     if (root == null)
     {
         throw new ArgumentNullException(nameof(root));
     }
     Root = root;
 }
Esempio n. 4
0
        public void Add(YAMLNode key, YAMLNode value)
        {
            if (key.NodeType != YAMLNodeType.Scalar)
            {
                throw new Exception($"Only {YAMLNodeType.Scalar} node as a key supported");
            }

            InsertEnd(key, value);
        }
Esempio n. 5
0
        internal override void Emit(Emitter emitter)
        {
            base.Emit(emitter);

            StartChildren(emitter);
            for (int i = 0; i < m_children.Count; i++)
            {
                YAMLNode child = m_children[i];
                StartChild(emitter, child);
                child.Emit(emitter);
                EndChild(emitter, child);
            }
            EndChildren(emitter);
        }
Esempio n. 6
0
 private void EndChild(Emitter emitter, YAMLNode next)
 {
     if (Style == SequenceStyle.Block)
     {
         emitter.WriteLine();
     }
     else if (Style == SequenceStyle.Flow)
     {
         emitter.WriteSeparator().WriteWhitespace();
     }
     if (next.IsIndent)
     {
         emitter.DecreaseIntent();
     }
 }
Esempio n. 7
0
 private void EndTransition(Emitter emitter, YAMLNode next)
 {
     if (Style == MappingStyle.Block)
     {
         emitter.WriteLine();
     }
     else if (Style == MappingStyle.Flow)
     {
         emitter.WriteSeparator().WriteWhitespace();
     }
     if (next.IsIndent)
     {
         emitter.DecreaseIntent();
     }
 }
Esempio n. 8
0
 private void StartTransition(Emitter emitter, YAMLNode next)
 {
     emitter.Write(':').WriteWhitespace();
     if (Style == MappingStyle.Block)
     {
         if (next.IsMultyline)
         {
             emitter.WriteLine();
         }
     }
     if (next.IsIndent)
     {
         emitter.IncreaseIntent();
     }
 }
Esempio n. 9
0
        private void StartChild(Emitter emitter, YAMLNode next)
        {
            if (Style == SequenceStyle.Block)
            {
                emitter.Write('-').WriteWhitespace();

                if (next.NodeType == NodeType)
                {
                    emitter.WriteLine();
                }
            }
            if (next.IsIndent)
            {
                emitter.IncreaseIntent();
            }
        }
Esempio n. 10
0
        internal override void Emit(Emitter emitter)
        {
            base.Emit(emitter);

            StartChildren(emitter);
            foreach (var kvp in m_children)
            {
                YAMLNode key   = kvp.Key;
                YAMLNode value = kvp.Value;

                key.Emit(emitter);
                StartTransition(emitter, value);
                value.Emit(emitter);
                EndTransition(emitter, value);
            }
            EndChildren(emitter);
        }
Esempio n. 11
0
        public static YAMLNode ExportYAML <T>(this IReadOnlyDictionary <T, float> _this)
            where T : IYAMLExportable
        {
            YAMLSequenceNode node = new YAMLSequenceNode();

            node.Style = SequenceStyle.Block;
            foreach (var kvp in _this)
            {
                YAMLMappingNode map = new YAMLMappingNode();
                YAMLNode        key = kvp.Key.ExportYAML();
                if (key.NodeType == YAMLNodeType.Scalar)
                {
                    map.Add(key, kvp.Value);
                }
                else
                {
                    map.Add("first", key);
                    map.Add("second", kvp.Value);
                }
                node.Add(map);
            }
            return(node);
        }
Esempio n. 12
0
 public void Add(YAMLNode child)
 {
     m_children.Add(child);
 }
Esempio n. 13
0
        public void Add(YAMLNode key, bool value)
        {
            YAMLScalarNode valueNode = new YAMLScalarNode(value);

            Add(key, valueNode);
        }
Esempio n. 14
0
        private void InsertEnd(YAMLNode key, YAMLNode value)
        {
            KeyValuePair <YAMLNode, YAMLNode> pair = new KeyValuePair <YAMLNode, YAMLNode>(key, value);

            m_children.Add(pair);
        }
Esempio n. 15
0
        public void InsertBegin(YAMLNode key, YAMLNode value)
        {
            KeyValuePair <YAMLNode, YAMLNode> pair = new KeyValuePair <YAMLNode, YAMLNode>(key, value);

            m_children.Insert(0, pair);
        }