[NUI]Add xaml support for nui and nui xaml test sample (#230)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Xaml / XmlName.cs
1 using System.Diagnostics;
2
3 namespace Tizen.NUI.Xaml
4 {
5         [DebuggerDisplay("{NamespaceURI}:{LocalName}")]
6         internal struct XmlName
7         {
8                 public static readonly XmlName _CreateContent = new XmlName("_", "CreateContent");
9                 public static readonly XmlName xKey = new XmlName("x", "Key");
10                 public static readonly XmlName xName = new XmlName("x", "Name");
11                 public static readonly XmlName xTypeArguments = new XmlName("x", "TypeArguments");
12                 public static readonly XmlName xArguments = new XmlName("x", "Arguments");
13                 public static readonly XmlName xFactoryMethod = new XmlName("x", "FactoryMethod");
14                 public static readonly XmlName xDataType = new XmlName("x", "DataType");
15                 public static readonly XmlName Empty = new XmlName();
16
17                 public string NamespaceURI { get; }
18                 public string LocalName { get; }
19
20                 public XmlName(string namespaceUri, string localName)
21                 {
22                         NamespaceURI = namespaceUri;
23                         LocalName = localName;
24                 }
25
26                 public override bool Equals(object obj)
27                 {
28                         if (obj == null)
29                                 return false;
30                         if (obj.GetType() != typeof (XmlName))
31                                 return false;
32                         var other = (XmlName)obj;
33                         return NamespaceURI == other.NamespaceURI && LocalName == other.LocalName;
34                 }
35
36                 public bool Equals(string namespaceUri, string localName)
37                         => Equals(new XmlName(namespaceUri, localName));
38
39                 public override int GetHashCode()
40                 {
41                         unchecked
42                         {
43                                 int hashCode = 0;
44                                 if (NamespaceURI != null)
45                                         hashCode = NamespaceURI.GetHashCode();
46                                 if (LocalName != null)
47                                         hashCode = (hashCode * 397) ^ LocalName.GetHashCode();
48                                 return hashCode;
49                         }
50                 }
51
52                 public static bool operator ==(XmlName x1, XmlName x2)
53                         => x1.NamespaceURI == x2.NamespaceURI && x1.LocalName == x2.LocalName;
54
55                 public static bool operator !=(XmlName x1, XmlName x2)
56                         =>  !(x1 == x2);
57         }
58 }