-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStateContainer.cs
More file actions
37 lines (30 loc) · 938 Bytes
/
StateContainer.cs
File metadata and controls
37 lines (30 loc) · 938 Bytes
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
namespace DeswapApp;
public class StateContainer
{
private IList<UserNftBase> CachedNftsInner { get; set; } = [];
public IList<UserNftBase> CachedNfts
{
get => CachedNftsInner;
set
{
CachedNftsInner = value;
NotifyStateChanged();
}
}
private Dictionary<string, IList<UserNftBase>> CachedContractNftsInner { get; set; } = [];
public IList<UserNftBase> GetContractNfts(string contractAddress)
{
if (CachedContractNftsInner.TryGetValue(contractAddress, out IList<UserNftBase>? value))
{
return value ?? [];
}
return [];
}
public void SetContractNfts(string contractAddress, IList<UserNftBase> value)
{
CachedContractNftsInner[contractAddress] = value;
NotifyStateChanged();
}
public event Action? OnChange;
private void NotifyStateChanged() => OnChange?.Invoke();
}