ChameleonKey.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / schema / ChameleonKey.cs / 1 / ChameleonKey.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// [....] 
//-----------------------------------------------------------------------------
 
namespace System.Xml.Schema { 

    using System.Collections; 
    using System.ComponentModel;
    using System.Xml.Serialization;

    // Case insensitive file name key for use in a hashtable. 

    internal class ChameleonKey { 
        internal string targetNS; 
        internal Uri chameleonLocation;
        int hashCode; 

        public ChameleonKey(string ns, Uri location) {
            targetNS = ns;
            chameleonLocation = location; 
        }
 
        public override int GetHashCode() { 
            if (hashCode == 0) {
                hashCode = targetNS.GetHashCode() + chameleonLocation.GetHashCode(); 
            }
            return hashCode;
        }
 
        public override bool Equals(object obj) {
            if (Ref.ReferenceEquals(this,obj)) { 
                return true; 
            }
            ChameleonKey cKey = obj as ChameleonKey; 
            if (cKey != null) {
                return this.targetNS.Equals(cKey.targetNS) && this.chameleonLocation.Equals(cKey.chameleonLocation);
            }
            return false; 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK