Skybound.Gecko.GeckoNode.Equals C# (CSharp) Méthode

Equals() public méthode

public Equals ( object obj ) : bool
obj object
Résultat bool
        public override bool Equals(object obj)
        {
            if (this == obj)
                return true;
            else if (obj is GeckoNode)
                return this.GetHashCode() == (obj as GeckoNode).GetHashCode();

            return base.Equals(obj);
        }

Usage Example

 /// <summary>
 /// Gets the DOM id of a node relative to this node, as defined by us.
 /// </summary>
 /// 
 /// <remarks>The DOM id is the index of the given node in a depht-first search
 /// of the DOM tree. It is designed to give a good enough reference to a node
 /// that does not have an id attribute. This fails more or less depending on
 /// the amout of dynamic content inside the page.</remarks>
 /// <param name="root">Root element where to begin the search</param>
 /// <param name="node">Node to search for.</param>
 /// <returns>The DOM id of the node, or 0 if not found</returns>
 public static int GetDomId(this GeckoNode root, GeckoNode node)
 {
     int i = 0;
     foreach (var iter in root.TraverseDom ())
     {
         i++;
         if (node.Equals (iter))
             return i;
     }
     return 0;
 }