blob: d9619b72bc9b4d1b9a61cf0ee2afe281aeaae049 (
plain) (
blame)
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
|
namespace LibMatrix.Extensions;
public static class EnumerableExtensions {
public static void MergeStateEventLists(this List<StateEvent> oldState, List<StateEvent> newState) {
foreach (var stateEvent in newState) {
var old = oldState.FirstOrDefault(x => x.Type == stateEvent.Type && x.StateKey == stateEvent.StateKey);
if (old is null) {
oldState.Add(stateEvent);
continue;
}
oldState.Remove(old);
oldState.Add(stateEvent);
}
}
public static void MergeStateEventLists(this List<StateEventResponse> oldState, List<StateEventResponse> newState) {
foreach (var stateEvent in newState) {
var old = oldState.FirstOrDefault(x => x.Type == stateEvent.Type && x.StateKey == stateEvent.StateKey);
if (old is null) {
oldState.Add(stateEvent);
continue;
}
oldState.Remove(old);
oldState.Add(stateEvent);
}
}
}
|