HamBook – Blame information for rev 58

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 {
58 office 10 private readonly ConcurrentDictionary<NotificationType, NotificationState> _notificationStates =
54 office 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  
58 office 25 /*
55 office 26 foreach (var state in _notificationState)
27 {
28 _notificationStates.TryAdd(state.Type, state);
58 office 29 }*/
54 office 30 }
31  
12 office 32 public NotificationState[] State
33 {
34 get => _notificationState;
35 set
36 {
54 office 37 if (value == _notificationState) return;
12 office 38  
39 _notificationState = value;
58 office 40 foreach (var state in value)
41 {
42 _notificationStates.AddOrUpdate(state.Type, state, (k, v) => state);
43 }
12 office 44 OnPropertyChanged();
45 }
46 }
47  
54 office 48 public event PropertyChangedEventHandler PropertyChanged;
12 office 49  
50 public bool TryGetNotificationState(NotificationType notificationType, out NotificationState notificationState)
51 {
52 return _notificationStates.TryGetValue(notificationType, out notificationState);
53 }
54  
55 [NotifyPropertyChangedInvocator]
56 protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
57 {
58 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
59 }
60 }
54 office 61 }