public void Add(string anchor_name, YamlNode node) { if ( Items.ContainsKey(anchor_name) ) { // override an existing anchor ItemsToRewind.Push(new RewindInfo(anchor_name, this[anchor_name])); Items[anchor_name] = node; } else { ItemsToRewind.Push(new RewindInfo(anchor_name, null)); Items.Add(anchor_name, node); } }
public RewindInfo(string anchor_name, YamlNode old_value) { this.anchor_name = anchor_name; this.old_value = old_value; }
public static void outputNode(YamlNode node,string ind="") { Console.WriteLine(ind+"NODE:\n{0}", ind+node.Tag); if (node.GetType() == typeof(YamlMapping)) foreach (YamlNode n in ((YamlMapping)node).Keys) { outputNode(n,ind+"-"); } else if (node.GetType() == typeof(YamlScalar)) Console.WriteLine("{0}\n", ind+((YamlScalar)node)); }
internal override bool Equals(YamlNode b, ObjectRepository repository) { bool skip; if(! base.EqualsSub(b, repository, out skip) ) return false; if(skip) return true; YamlScalar aa = this; YamlScalar bb = (YamlScalar)b; if ( NativeObjectAvailable ) { return bb.NativeObjectAvailable && (aa.NativeObject == null ? bb.NativeObject==null : aa.NativeObject.Equals(bb.NativeObject) ); } else { if ( ShorthandTag() == "!!str" ) { return aa.Value == bb.Value; } else { // Node with non standard tag is compared by its identity. return false; } } }
public bool AlreadyAppeared(YamlNode a, YamlNode b, out bool identity) { int ai, bi; bool ar = nodes_a.TryGetValue(a, out ai); bool br = nodes_b.TryGetValue(b, out bi); if ( ar && br && ai == bi ) { identity = true; return true; } if ( ar ^ br ) { identity = false; return true; } nodes_a.Add(a, nodes_a.Count); nodes_b.Add(b, nodes_b.Count); stack_a.Push(a); stack_b.Push(b); if ( a == b ) { identity = true; return true; } identity = false; return false; }
/// <summary> /// Returns true if <paramref name="b"/> is of same type as the <see cref="YamlNode"/> and /// its Tag is same as the node. It returns true for <paramref name="skip"/> if they /// both already appeared in the node trees and were compared. /// </summary> /// <param name="b">Node to be compared.</param> /// <param name="repository">Node repository holds the nodes that already appeared and /// the corresponding node in the other node tree.</param> /// <param name="skip">true if they already appeared in the node tree and were compared.</param> /// <returns>true if they are equal to each other.</returns> internal bool EqualsSub(YamlNode b, ObjectRepository repository, out bool skip) { YamlNode a = this; bool identity; if ( repository.AlreadyAppeared(a, b, out identity) ) { skip = true; return identity; } skip = false; if ( a.GetType() != b.GetType() || a.Tag != b.Tag ) return false; return true; }
/// <summary> /// Returns true if <paramref name="b"/> is of same type as the <see cref="YamlNode"/> and /// its content is also logically same. /// </summary> /// <param name="b">Node to be compared.</param> /// <param name="repository">Node repository holds the nodes that already appeared and /// the corresponding node in the other node tree.</param> /// <returns>true if they are equal to each other.</returns> internal abstract bool Equals(YamlNode b, ObjectRepository repository);