HamBook – Rev 58
?pathlinks?
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Configuration.Annotations;
namespace Configuration
{
public class Notifications : INotifyPropertyChanged
{
private readonly ConcurrentDictionary<NotificationType, NotificationState> _notificationStates =
new ConcurrentDictionary<NotificationType, NotificationState>();
private NotificationState[] _notificationState =
{
new NotificationState { Type = NotificationType.SignalScanDetect, Enabled = false, LingerTime = 1000 }
};
public Notifications()
{
if (_notificationStates.Count != 0)
{
return;
}
/*
foreach (var state in _notificationState)
{
_notificationStates.TryAdd(state.Type, state);
}*/
}
public NotificationState[] State
{
get => _notificationState;
set
{
if (value == _notificationState) return;
_notificationState = value;
foreach (var state in value)
{
_notificationStates.AddOrUpdate(state.Type, state, (k, v) => state);
}
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
public bool TryGetNotificationState(NotificationType notificationType, out NotificationState notificationState)
{
return _notificationStates.TryGetValue(notificationType, out notificationState);
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Generated by GNU Enscript 1.6.5.90.