add gethashcode to filereplacementdto
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MareSynchronos.API
|
namespace MareSynchronos.API
|
||||||
{
|
{
|
||||||
@@ -6,5 +7,21 @@ namespace MareSynchronos.API
|
|||||||
{
|
{
|
||||||
public string[] GamePaths { get; set; } = Array.Empty<string>();
|
public string[] GamePaths { get; set; } = Array.Empty<string>();
|
||||||
public string Hash { get; set; }
|
public string Hash { get; set; }
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return HashCode.Combine(GetOrderIndependentHashCode(GamePaths), Hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetOrderIndependentHashCode<T>(IEnumerable<T> source)
|
||||||
|
{
|
||||||
|
int hash = 0;
|
||||||
|
foreach (T element in source)
|
||||||
|
{
|
||||||
|
hash = unchecked(hash +
|
||||||
|
EqualityComparer<T>.Default.GetHashCode(element));
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user