summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml/XmlName.cs
blob: 09cf3bca624e2cbaf79fae4b4c1f4fb48aed0bca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Diagnostics;

namespace Xamarin.Forms.Xaml
{
	[DebuggerDisplay("{NamespaceURI}:{LocalName}")]
	internal struct XmlName
	{
		public static readonly XmlName _CreateContent = new XmlName("_", "CreateContent");
		public static readonly XmlName xKey = new XmlName("x", "Key");
		public static readonly XmlName xName = new XmlName("x", "Name");
		public static readonly XmlName xTypeArguments = new XmlName("x", "TypeArguments");
		public static readonly XmlName xArguments = new XmlName("x", "Arguments");
		public static readonly XmlName xFactoryMethod = new XmlName("x", "xFactoryMethod");
		public static readonly XmlName Empty = new XmlName();

		public string NamespaceURI { get; }

		public string LocalName { get; }

		public XmlName(string namespaceUri, string localName)
		{
			NamespaceURI = namespaceUri;
			LocalName = localName;
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
				return false;
			if (obj.GetType() != typeof (XmlName))
				return false;
			var other = (XmlName)obj;
			return NamespaceURI == other.NamespaceURI && LocalName == other.LocalName;
		}

		public override int GetHashCode()
		{
			unchecked
			{
				int hashCode = 0;
				if (NamespaceURI != null)
					hashCode = NamespaceURI.GetHashCode();
				if (LocalName != null)
					hashCode = (hashCode * 397) ^ LocalName.GetHashCode();
				return hashCode;
			}
		}

		public static bool operator ==(XmlName x1, XmlName x2)
		{
			return x1.NamespaceURI == x2.NamespaceURI && x1.LocalName == x2.LocalName;
		}

		public static bool operator !=(XmlName x1, XmlName x2)
		{
			return !(x1 == x2);
		}
	}
}