diff --git a/VectoCore/VectoCore/Utils/XAttributeEqualityComparer.cs b/VectoCore/VectoCore/Utils/XAttributeEqualityComparer.cs new file mode 100644 index 0000000000000000000000000000000000000000..5a89d33169735f82cb35d60a246d7461ebaeec5e --- /dev/null +++ b/VectoCore/VectoCore/Utils/XAttributeEqualityComparer.cs @@ -0,0 +1,37 @@ +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; + } + } + } +} diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 36b3a28062de00f9a82907333d04a0e6768c06a4..df94559810b2ace2fb1882d0b84959a7dc5fda6e 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -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" />