1 //------------------------------------------------------------------------------
2 // <copyright file="XmlNavigatorReader.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
9 using System.Xml.Schema;
10 using System.Collections;
11 using System.Diagnostics;
12 using MS.Internal.Xml.Cache;
14 namespace System.Xml.XPath {
15 internal class XPathNavigatorKeyComparer : IEqualityComparer {
16 bool IEqualityComparer.Equals( Object obj1, Object obj2 ) {
17 XPathNavigator nav1 = obj1 as XPathNavigator;
18 XPathNavigator nav2 = obj2 as XPathNavigator;
19 if( ( nav1 != null ) && ( nav2 != null ) ) {
20 if( nav1.IsSamePosition( nav2 ) )
26 int IEqualityComparer.GetHashCode ( Object obj ) {
29 XPathDocumentNavigator xpdocNav;
32 throw new ArgumentNullException("obj");
34 else if ( null != (xpdocNav = obj as XPathDocumentNavigator) ) {
35 hashCode = xpdocNav.GetPositionHashCode();
37 else if( null != (nav = obj as XPathNavigator) ) {
38 Object underlyingObject = nav.UnderlyingObject;
39 if (underlyingObject != null) {
40 hashCode = underlyingObject.GetHashCode();
43 hashCode = (int)nav.NodeType;
44 hashCode ^= nav.LocalName.GetHashCode();
45 hashCode ^= nav.Prefix.GetHashCode();
46 hashCode ^= nav.NamespaceURI.GetHashCode();
50 hashCode = obj.GetHashCode();