From 91143894e5314670595c9fe3f364c27280fa2391 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Sun, 24 Jul 2022 12:22:29 +0200 Subject: [PATCH] add gethashcode to filereplacementdto --- MareSynchronosAPI/FileReplacementDto.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MareSynchronosAPI/FileReplacementDto.cs b/MareSynchronosAPI/FileReplacementDto.cs index 57aa2cb..9156856 100644 --- a/MareSynchronosAPI/FileReplacementDto.cs +++ b/MareSynchronosAPI/FileReplacementDto.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace MareSynchronos.API { @@ -6,5 +7,21 @@ namespace MareSynchronos.API { public string[] GamePaths { get; set; } = Array.Empty(); public string Hash { get; set; } + + public override int GetHashCode() + { + return HashCode.Combine(GetOrderIndependentHashCode(GamePaths), Hash); + } + + public static int GetOrderIndependentHashCode(IEnumerable source) + { + int hash = 0; + foreach (T element in source) + { + hash = unchecked(hash + + EqualityComparer.Default.GetHashCode(element)); + } + return hash; + } } } \ No newline at end of file