2 // System.Xml.XmlQualifiedName.cs
4 // Author: Duncan Mak (duncan@ximian.com)
9 // 21st June 2002 : Ajay kumar Dwivedi (adwiv@yahoo.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 public class XmlQualifiedName
39 public XmlQualifiedName ()
40 : this (string.Empty, string.Empty)
44 public XmlQualifiedName (string name)
45 : this (name, string.Empty)
49 public XmlQualifiedName (string name, string ns)
52 this.name = (name == null) ? "" : name;
53 this.ns = (ns == null) ? "" : ns;
54 this.hash = this.name.GetHashCode () ^ this.ns.GetHashCode ();
58 public static readonly XmlQualifiedName Empty = new XmlQualifiedName ();
59 private readonly string name;
60 private readonly string ns;
61 private readonly int hash;
67 return name.Length == 0 && ns.Length == 0;
76 public string Namespace
82 public override bool Equals (object other)
84 return this == (other as XmlQualifiedName);
87 public override int GetHashCode ()
92 public override string ToString ()
94 if (ns == string.Empty)
97 return ns + ":" + name;
100 public static string ToString (string name, string ns)
102 if (ns == string.Empty)
105 return ns + ":" + name;
109 public static bool operator == (XmlQualifiedName a, XmlQualifiedName b)
111 if((Object)a == (Object)b)
114 if((Object)a == null || (Object)b == null)
117 return (a.hash == b.hash) && (a.name == b.name) && (a.ns == b.ns);
120 public static bool operator != (XmlQualifiedName a, XmlQualifiedName b)