Repository navigation
Expand file tree
/
Copy pathVirtualChangeSet.cs
More file actions
63 lines (49 loc) · 2.06 KB
/
Copy pathVirtualChangeSet.cs
File metadata and controls
63 lines (49 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2011-2023 Roland Pheasant. All rights reserved.
// Roland Pheasant licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
using DynamicData.Cache.Internal;
// ReSharper disable once CheckNamespace
namespace DynamicData;
internal sealed class VirtualChangeSet<TObject, TKey> : ChangeSet<TObject, TKey>, IVirtualChangeSet<TObject, TKey>, IEquatable<VirtualChangeSet<TObject, TKey>>
where TObject : notnull
where TKey : notnull
{
public static new readonly IVirtualChangeSet<TObject, TKey> Empty = new VirtualChangeSet<TObject, TKey>();
public VirtualChangeSet(IEnumerable<Change<TObject, TKey>> items, IKeyValueCollection<TObject, TKey> sortedItems, IVirtualResponse response)
: base(items)
{
SortedItems = sortedItems;
Response = response;
}
private VirtualChangeSet()
{
SortedItems = new KeyValueCollection<TObject, TKey>();
Response = new VirtualResponse(0, 0, 0);
}
public IVirtualResponse Response { get; }
public IKeyValueCollection<TObject, TKey> SortedItems { get; }
public static bool operator ==(VirtualChangeSet<TObject, TKey> left, VirtualChangeSet<TObject, TKey> right) => Equals(left, right);
public static bool operator !=(VirtualChangeSet<TObject, TKey> left, VirtualChangeSet<TObject, TKey> right) => !Equals(left, right);
public bool Equals(VirtualChangeSet<TObject, TKey>? other)
{
if (other is null)
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return Response.Equals(other.Response) && Equals(SortedItems, other.SortedItems);
}
public override bool Equals(object? obj) => obj is VirtualChangeSet<TObject, TKey> item && Equals(item);
public override int GetHashCode()
{
unchecked
{
var hashCode = Response.GetHashCode();
hashCode = (hashCode * 397) ^ SortedItems.GetHashCode();
return hashCode;
}
}
}