adjust DTOs
This commit is contained in:
@@ -1,12 +1,50 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace MareSynchronos.API
|
namespace MareSynchronos.API
|
||||||
{
|
{
|
||||||
public record CharacterCacheDto
|
public class CharacterCacheDto
|
||||||
{
|
{
|
||||||
public Dictionary<ObjectKind, List<FileReplacementDto>> FileReplacements { get; set; } = new();
|
public Dictionary<ObjectKind, List<FileReplacementDto>> FileReplacements { get; set; } = new();
|
||||||
public Dictionary<ObjectKind, string> GlamourerData { get; set; } = new();
|
public Dictionary<ObjectKind, string> GlamourerData { get; set; } = new();
|
||||||
public string ManipulationData { get; set; } = string.Empty;
|
public string ManipulationData { get; set; } = string.Empty;
|
||||||
public string Hash { get; set; } = string.Empty;
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return GetHashCode() + Environment.NewLine + "Manip:" + ManipulationData + Environment.NewLine
|
||||||
|
+ string.Join(Environment.NewLine, GlamourerData.Select(g => g.Key + ":" + g.Value)) + Environment.NewLine
|
||||||
|
+ string.Join(Environment.NewLine, FileReplacements.Select(g => g.Key + Environment.NewLine + string.Join(Environment.NewLine, g.Value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
int fileReplacementsHash = 0;
|
||||||
|
foreach (var item in FileReplacements)
|
||||||
|
{
|
||||||
|
foreach (var values in item.Value)
|
||||||
|
{
|
||||||
|
fileReplacementsHash = unchecked(fileReplacementsHash + values.GetHashCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int glamourerHash = 0;
|
||||||
|
foreach (var item in GlamourerData)
|
||||||
|
{
|
||||||
|
glamourerHash = unchecked(glamourerHash + item.Value.GetHashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
return HashCode.Combine(fileReplacementsHash, glamourerHash, ManipulationData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace MareSynchronos.API
|
namespace MareSynchronos.API
|
||||||
{
|
{
|
||||||
public record FileReplacementDto
|
public class FileReplacementDto
|
||||||
{
|
{
|
||||||
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 bool Equals(object? otherObj)
|
||||||
|
{
|
||||||
|
if (otherObj == null || otherObj is not FileReplacementDto other) return false;
|
||||||
|
return Hash == other.Hash && Enumerable.SequenceEqual(GamePaths, other.GamePaths);
|
||||||
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine(GetOrderIndependentHashCode(GamePaths), Hash);
|
return HashCode.Combine(GetOrderIndependentHashCode(GamePaths), Hash);
|
||||||
@@ -23,5 +30,10 @@ namespace MareSynchronos.API
|
|||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Hash + ":" + string.Join(",", GamePaths);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user