HamBook – Blame information for rev 54
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
54 | office | 1 | using System.Collections.Concurrent; |
12 | office | 2 | using System.ComponentModel; |
3 | using System.Runtime.CompilerServices; |
||
54 | office | 4 | using Configuration.Annotations; |
12 | office | 5 | |
6 | namespace Configuration |
||
7 | { |
||
8 | public class Notifications : INotifyPropertyChanged |
||
9 | { |
||
54 | office | 10 | private static readonly ConcurrentDictionary<NotificationType, NotificationState> _notificationStates = |
11 | new ConcurrentDictionary<NotificationType, NotificationState>(); |
||
12 | |||
13 | private NotificationState[] _notificationState = |
||
12 | office | 14 | { |
54 | office | 15 | new NotificationState { Type = NotificationType.SignalScanDetect, Enabled = false, LingerTime = 1000 } |
12 | office | 16 | }; |
17 | |||
54 | office | 18 | public Notifications() |
19 | { |
||
20 | if (_notificationStates.Count == 0) |
||
21 | foreach (var state in _notificationState) |
||
22 | _notificationStates.TryAdd(state.Type, state); |
||
23 | } |
||
24 | |||
12 | office | 25 | public NotificationState[] State |
26 | { |
||
27 | get => _notificationState; |
||
28 | set |
||
29 | { |
||
54 | office | 30 | if (value == _notificationState) return; |
12 | office | 31 | |
32 | _notificationState = value; |
||
33 | OnPropertyChanged(); |
||
34 | } |
||
35 | } |
||
36 | |||
54 | office | 37 | public event PropertyChangedEventHandler PropertyChanged; |
12 | office | 38 | |
39 | public bool TryGetNotificationState(NotificationType notificationType, out NotificationState notificationState) |
||
40 | { |
||
41 | return _notificationStates.TryGetValue(notificationType, out notificationState); |
||
42 | } |
||
43 | |||
44 | [NotifyPropertyChangedInvocator] |
||
45 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
||
46 | { |
||
47 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
||
48 | } |
||
49 | } |
||
54 | office | 50 | } |