HamBook – Blame information for rev 54

Subversion Repositories:
Rev:
Rev Author Line No. Line
54 office 1 using System.Collections.Concurrent;
5 office 2 using System.ComponentModel;
3 using System.Runtime.CompilerServices;
54 office 4 using Configuration.Annotations;
5 office 5  
6 namespace Configuration
7 {
8 public class Definitions : INotifyPropertyChanged
9 {
54 office 10 private static readonly ConcurrentDictionary<int, Band> _metersToBand = new ConcurrentDictionary<int, Band>();
11  
12 private Band[] _bands =
5 office 13 {
12 office 14 new Band { Meters = 6, Min = 050000000, Max = 054000000 },
15 new Band { Meters = 10, Min = 028000000, Max = 029700000 },
16 new Band { Meters = 11, Min = 026965000, Max = 027405000 },
17 new Band { Meters = 12, Min = 024920000, Max = 024990000 },
18 new Band { Meters = 15, Min = 021000000, Max = 021450000 },
19 new Band { Meters = 17, Min = 018068000, Max = 018168000 },
20 new Band { Meters = 20, Min = 014000000, Max = 014350000 },
21 new Band { Meters = 30, Min = 010100000, Max = 010150000 },
54 office 22 new Band { Meters = 40, Min = 007000000, Max = 007300000 }
12 office 23 };
24  
54 office 25 public Definitions()
26 {
27 if (_metersToBand.Count == 0)
28 foreach (var band in _bands)
29 _metersToBand.TryAdd(band.Meters, band);
30 }
31  
12 office 32 public Band[] Bands
33 {
5 office 34 get => _bands;
35 set
36 {
54 office 37 if (value == _bands) return;
5 office 38  
39 _metersToBand.Clear();
54 office 40 foreach (var band in value) _metersToBand.TryAdd(band.Meters, band);
5 office 41  
42 _bands = value;
43  
44 OnPropertyChanged();
45 }
46 }
47  
54 office 48 public event PropertyChangedEventHandler PropertyChanged;
5 office 49  
50 /// <summary>
54 office 51 /// Retrieve the minimum and maximum frequency from meters.
5 office 52 /// </summary>
53 /// <param name="meters">meters corresponding to a band</param>
54 /// <param name="band">the band</param>
55 /// <returns>true upon a band definition existing</returns>
56 public bool TryGetBand(int meters, out Band band)
57 {
58 return _metersToBand.TryGetValue(meters, out band);
59 }
60  
61 [NotifyPropertyChangedInvocator]
62 protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
63 {
64 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
65 }
66 }
54 office 67 }