[NUI] Add file comment and end empty line
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.XamlBuild / src / internal / Xaml / XmlName.cs
1 /*
2  * Copyright(c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System.Diagnostics;
18
19 namespace Tizen.NUI.Xaml
20 {
21     [DebuggerDisplay("{NamespaceURI}:{LocalName}")]
22     internal struct XmlName
23     {
24         public static readonly XmlName _CreateContent = new XmlName("_", "CreateContent");
25         public static readonly XmlName xKey = new XmlName("x", "Key");
26         public static readonly XmlName xName = new XmlName("x", "Name");
27         public static readonly XmlName xTypeArguments = new XmlName("x", "TypeArguments");
28         public static readonly XmlName xArguments = new XmlName("x", "Arguments");
29         public static readonly XmlName xFactoryMethod = new XmlName("x", "FactoryMethod");
30         public static readonly XmlName xDataType = new XmlName("x", "DataType");
31         public static readonly XmlName Empty = new XmlName();
32
33         public string NamespaceURI { get; }
34         public string LocalName { get; }
35
36         public XmlName(string namespaceUri, string localName)
37         {
38             NamespaceURI = namespaceUri;
39             LocalName = localName;
40         }
41
42         public override bool Equals(object obj)
43         {
44             if (obj == null)
45                 return false;
46             if (obj.GetType() != typeof (XmlName))
47                 return false;
48             var other = (XmlName)obj;
49             return NamespaceURI == other.NamespaceURI && LocalName == other.LocalName;
50         }
51
52         public bool Equals(string namespaceUri, string localName)
53             => Equals(new XmlName(namespaceUri, localName));
54
55         public override int GetHashCode()
56         {
57             unchecked
58             {
59                 int hashCode = 0;
60                 if (NamespaceURI != null)
61                     hashCode = NamespaceURI.GetHashCode();
62                 if (LocalName != null)
63                     hashCode = (hashCode * 397) ^ LocalName.GetHashCode();
64                 return hashCode;
65             }
66         }
67
68         public static bool operator ==(XmlName x1, XmlName x2)
69             => x1.NamespaceURI == x2.NamespaceURI && x1.LocalName == x2.LocalName;
70
71         public static bool operator !=(XmlName x1, XmlName x2)
72             =>  !(x1 == x2);
73     }
74 }
75