HamBook – Diff between revs 44 and 46
?pathlinks?
Rev 44 | Rev 46 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | using System; |
1 | using System; |
|
2 | using System.Collections.Generic; |
2 | using System.Collections.Generic; |
|
3 | using System.Linq; |
3 | using System.Linq; |
|
- | 4 | using System.Reflection; |
||
4 | using System.Text; |
5 | using System.Text; |
|
5 | using System.Threading.Tasks; |
6 | using System.Threading.Tasks; |
|
6 | using System.Xml.Serialization; |
7 | using System.Xml.Serialization; |
|
Line 7... | Line 8... | |||
7 | |
8 | |
|
8 | namespace HamBook.Radios.Generic |
9 | namespace HamBook.Radios.Generic |
|
- | 10 | { |
||
9 | { |
11 | [XmlRoot(Namespace = "Generic")] |
|
10 | public class MemoryChannel : IEquatable<MemoryChannel> |
12 | public abstract class MemoryChannel : IEquatable<MemoryChannel> |
|
- | 13 | { |
||
11 | { |
14 | [XmlIgnore] |
|
12 | public string CurrentLocation { get; set; } |
- | ||
13 | |
15 | public abstract string CurrentLocation { get; set; } |
|
14 | public int Frequency { get; set; } |
- | ||
15 | |
- | ||
16 | public ClarifierDirection ClarifierDirection { get; set; } |
- | ||
17 | |
16 | [XmlIgnore] |
|
18 | public int ClarifierOffset { get; set; } |
- | ||
19 | |
17 | public abstract int Frequency { get; set; } |
|
20 | public bool Clar { get; set; } |
- | ||
21 | |
18 | [XmlIgnore] |
|
22 | public MemoryRadioMode MemoryRadioMode { get; set; } |
- | ||
23 | |
19 | public abstract string Text { get; set; } |
|
24 | public CtcssMode CtcssMode { get; set; } |
- | ||
25 | |
20 | [XmlIgnore] |
|
26 | public RadioPhase Phase { get; set; } |
- | ||
27 | |
21 | public abstract MemoryRadioMode MemoryRadioMode { get; set; } |
|
28 | public bool Tag { get; set; } |
- | ||
29 | |
22 | [XmlIgnore] |
|
Line 30... | Line 23... | |||
30 | public string Text { get; set; } |
23 | public abstract bool Tag { get; set; } |
|
31 | |
24 | |
|
32 | public MemoryChannel() |
25 | public MemoryChannel() |
|
Line 33... | Line 26... | |||
33 | { |
26 | { |
|
34 | } |
27 | } |
|
35 | |
28 | |
|
- | 29 | public static MemoryChannel Create(string radio, params object[] param) |
||
36 | public bool Equals(MemoryChannel other) |
30 | { |
|
- | 31 | foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) |
||
- | 32 | { |
||
- | 33 | foreach (var type in assembly.GetTypes()) |
||
37 | { |
34 | { |
|
- | 35 | if (typeof(MemoryChannel).IsAssignableFrom(type)) |
||
38 | return CurrentLocation == other.CurrentLocation && |
36 | { |
|
39 | Frequency == other.Frequency && |
37 | var radioAttribute = type.GetCustomAttribute<RadioAttribute>(); |
|
40 | ClarifierDirection.Direction == other.ClarifierDirection.Direction && |
38 | |
|
41 | ClarifierOffset == other.ClarifierOffset && |
39 | if (radioAttribute != null && radioAttribute.Radio == radio) |
|
42 | Clar == other.Clar && |
40 | { |
|
43 | MemoryRadioMode.Code == other.MemoryRadioMode.Code && |
41 | return (MemoryChannel)Activator.CreateInstance(type, param); |
|
- | 42 | } |
||
- | 43 | } |
||
44 | CtcssMode.Mode == other.CtcssMode.Mode && |
44 | } |
|
45 | Phase.Phase == other.Phase.Phase && |
45 | } |
|
- | 46 | |
||
- | 47 | return null; |
||
46 | Tag == other.Tag && |
48 | } |
|
47 | Text == other.Text; |
49 | |