/// <summary>
        /// Adds the specified node to the anchor list.
        /// </summary>
        /// <param name="node">The node.</param>
        public void AddAnchor(YamlNode node)
        {
            if (node.Anchor == null)
            {
                throw new ArgumentException("The specified node does not have an anchor");
            }

            if (anchors.ContainsKey(node.Anchor))
            {
                throw new DuplicateAnchorException(node.Start, node.End, string.Format(CultureInfo.InvariantCulture, "The anchor '{0}' already exists", node.Anchor));
            }

            anchors.Add(node.Anchor, node);
        }
Example #2
0
 /// <summary>
 /// Provides a basic implementation of Object.Equals 
 /// </summary>
 protected bool Equals(YamlNode other)
 {
     // Do not use the anchor in the equality comparison because that would prevent anchored nodes from being found in dictionaries.
     return SafeEquals(Tag, other.Tag);
 }
Example #3
0
 /// <summary>
 /// Provides a basic implementation of Object.Equals
 /// </summary>
 protected bool Equals(YamlNode other)
 {
     // Do not use the anchor in the equality comparison because that would prevent anchored nodes from being found in dictionaries.
     return(SafeEquals(Tag, other.Tag));
 }
 /// <summary>
 /// Adds the specified node to the collection of nodes with unresolved aliases.
 /// </summary>
 /// <param name="node">
 /// The <see cref="YamlNode"/> that has unresolved aliases.
 /// </param>
 public void AddNodeWithUnresolvedAliases(YamlNode node)
 {
     nodesWithUnresolvedAliases.Add(node);
 }
Example #5
0
 /// <summary>
 /// Called when this object is visiting a key-value pair.
 /// </summary>
 /// <param name="key">The left (key) <see cref="YamlNode"/> that is being visited.</param>
 /// <param name="value">The right (value) <see cref="YamlNode"/> that is being visited.</param>
 protected virtual void VisitPair(YamlNode key, YamlNode value)
 {
     key.Accept(this);
     value.Accept(this);
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="YamlDocument"/> class with a single scalar node.
 /// </summary>
 public YamlDocument(string rootNode)
 {
     RootNode = new YamlScalarNode(rootNode);
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="YamlDocument"/> class.
 /// </summary>
 public YamlDocument(YamlNode rootNode)
 {
     RootNode = rootNode;
 }
 /// <summary>
 /// Called when this object is visiting a key-value pair.
 /// </summary>
 /// <param name="key">The left (key) <see cref="YamlNode"/> that is being visited.</param>
 /// <param name="value">The right (value) <see cref="YamlNode"/> that is being visited.</param>
 protected virtual void VisitPair(YamlNode key, YamlNode value)
 {
     key.Accept(this);
     value.Accept(this);
 }