Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit c9964014 authored by Harald Martini's avatar Harald Martini
Browse files

Added XAttributeEqualityComparer

parent 604e4866
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace TUGraz.VectoCore.Utils
{
public class XAttributeEqualityComparer : IEqualityComparer<XAttribute>
{
public bool Equals(XAttribute x, XAttribute y)
{
if (ReferenceEquals(x, y))
return true;
if (ReferenceEquals(x, null))
return false;
if (ReferenceEquals(y, null))
return false;
if (x.GetType() != y.GetType())
return false;
return x.IsNamespaceDeclaration == y.IsNamespaceDeclaration && x.Name.Equals(y.Name) && x.NodeType == y.NodeType && x.Value == y.Value;
}
public int GetHashCode(XAttribute obj)
{
unchecked
{
var hashCode = obj.IsNamespaceDeclaration.GetHashCode();
hashCode = (hashCode * 397) ^ obj.Name.GetHashCode();
hashCode = (hashCode * 397) ^ (int)obj.NodeType;
hashCode = (hashCode * 397) ^ obj.Value.GetHashCode();
return hashCode;
}
}
}
}
......@@ -761,6 +761,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>VectoVersionCore.tt</DependentUpon>
</Compile>
<Compile Include="Utils\XAttributeEqualityComparer.cs" />
<Compile Include="Utils\XMLDefinitions.cs" />
<Compile Include="Utils\XMLHelper.cs" />
<Compile Include="Utils\XmlResourceResolver.cs" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment