HamBook – Blame information for rev 12

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