HamBook – Blame information for rev 55

Subversion Repositories:
Rev:
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 {
55 office 20 if (_notificationStates.Count != 0)
21 {
22 return;
23 }
24  
25 foreach (var state in _notificationState)
26 {
27 _notificationStates.TryAdd(state.Type, state);
28 }
54 office 29 }
30  
12 office 31 public NotificationState[] State
32 {
33 get => _notificationState;
34 set
35 {
54 office 36 if (value == _notificationState) return;
12 office 37  
38 _notificationState = value;
39 OnPropertyChanged();
40 }
41 }
42  
54 office 43 public event PropertyChangedEventHandler PropertyChanged;
12 office 44  
45 public bool TryGetNotificationState(NotificationType notificationType, out NotificationState notificationState)
46 {
47 return _notificationStates.TryGetValue(notificationType, out notificationState);
48 }
49  
50 [NotifyPropertyChangedInvocator]
51 protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
52 {
53 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
54 }
55 }
54 office 56 }