36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
#nullable enable
|
|
namespace Bts.DataStreamCore;
|
|
|
|
using BCG;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
|
|
public class BlueRowCollectionEqualityComparer : IEqualityComparer<IBlueRowCollection?> {
|
|
readonly IEqualityComparer<IBlueRow> rowComparer = BlueRowEqualityComparer.Instance;
|
|
|
|
public static BlueRowCollectionEqualityComparer Instance { get; } = new();
|
|
|
|
public bool Equals(IBlueRowCollection? x, IBlueRowCollection? y) {
|
|
if (x is null) {
|
|
return y is null;
|
|
}
|
|
if (x.Count != y?.Count) {
|
|
return false;
|
|
}
|
|
return x.schema.columnInfo.SequenceEqual(y.schema.columnInfo)
|
|
&& x.Cast<IBlueRow>().OrderBy(r => r.Id()).SequenceEqual(
|
|
y.Cast<IBlueRow>().OrderBy(r => r.Id()),
|
|
rowComparer);
|
|
}
|
|
|
|
public int GetHashCode([DisallowNull] IBlueRowCollection rows) {
|
|
var hash = new HashCode();
|
|
hash.Add(rows.schema.columnInfo.Length);
|
|
hash.Add(rows.Count);
|
|
return hash.ToHashCode();
|
|
}
|
|
}
|