Exemple #1
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);
        }
Exemple #2
0
        private void InsertEnd(YAMLNode key, YAMLNode value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            KeyValuePair <YAMLNode, YAMLNode> pair = new KeyValuePair <YAMLNode, YAMLNode>(key, value);

            m_children.Add(pair);
        }
Exemple #3
0
        public void InsertBegin(YAMLNode key, YAMLNode value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            KeyValuePair <YAMLNode, YAMLNode> pair = new KeyValuePair <YAMLNode, YAMLNode>(key, value);

            m_children.Insert(0, pair);
        }
Exemple #4
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();
     }
 }
Exemple #5
0
 private void StartTransition(Emitter emitter, YAMLNode next)
 {
     emitter.Write(':').WriteWhitespace();
     if (Style == MappingStyle.Block)
     {
         if (next.IsMultiline)
         {
             emitter.WriteLine();
         }
     }
     if (next.IsIndent)
     {
         emitter.IncreaseIntent();
     }
 }
        private void StartChild(Emitter emitter, YAMLNode next)
        {
            if (Style == SequenceStyle.Block || Style == SequenceStyle.BlockCurve)
            {
                emitter.Write('-').WriteWhitespace();

                if (next.NodeType == NodeType)
                {
                    emitter.IncreaseIntent();
                }
            }
            if (next.IsIndent)
            {
                emitter.IncreaseIntent();
            }
        }
Exemple #7
0
        private void StartChild(Emitter emitter, YAMLNode next)
        {
            if (Style.IsAnyBlock())
            {
                emitter.Write('-').Write(' ');

                if (next.NodeType == NodeType)
                {
                    emitter.IncreaseIndent();
                }
            }
            if (next.IsIndent)
            {
                emitter.IncreaseIndent();
            }
        }
Exemple #8
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);
        }
 private void EndChild(Emitter emitter, YAMLNode next)
 {
     if (Style.IsAnyBlock())
     {
         emitter.WriteLine();
         if (next.NodeType == NodeType)
         {
             emitter.DecreaseIntent();
         }
     }
     else if (Style == SequenceStyle.Flow)
     {
         emitter.WriteSeparator().WriteWhitespace();
     }
     if (next.IsIndent)
     {
         emitter.DecreaseIntent();
     }
 }
Exemple #10
0
        public void Add(long key, YAMLNode value)
        {
            YAMLScalarNode keyNode = new YAMLScalarNode(key);

            InsertEnd(keyNode, value);
        }
Exemple #11
0
        public void InsertBegin(string key, YAMLNode value)
        {
            YAMLScalarNode keyNode = new YAMLScalarNode(key, true);

            InsertBegin(keyNode, value);
        }
Exemple #12
0
        public void Add(YAMLNode key, string value)
        {
            YAMLScalarNode valueNode = new YAMLScalarNode(value);

            Add(key, valueNode);
        }
Exemple #13
0
        public void Add(YAMLNode key, ushort value)
        {
            YAMLScalarNode valueNode = new YAMLScalarNode(value);

            Add(key, valueNode);
        }
Exemple #14
0
 public void Add(YAMLNode child)
 {
     m_children.Add(child);
 }