blob: 0c98bfe622a0839aeddb01fcb9e4f7f333385a9b (
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 IList<StateEvent> oldState, IList<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 IList<StateEventResponse> oldState, IList<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);
}
}
}
|