HamBook – Blame information for rev 45
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
15 | office | 1 | using Org.BouncyCastle.Crypto.Tls; |
2 | using System; |
||
3 | using System.Collections.Generic; |
||
4 | using System.Linq; |
||
44 | office | 5 | using System.Reflection; |
15 | office | 6 | using System.Text; |
7 | using System.Threading.Tasks; |
||
45 | office | 8 | using System.Xml.Serialization; |
15 | office | 9 | |
10 | namespace HamBook.Radios.Generic |
||
11 | { |
||
45 | office | 12 | [XmlRoot(Namespace = "Generic")] |
44 | office | 13 | public abstract class MemoryRadioMode |
15 | office | 14 | { |
44 | office | 15 | public abstract char Code { get; } |
15 | office | 16 | |
44 | office | 17 | public abstract string Name { get; } |
15 | office | 18 | |
16 | office | 19 | public MemoryRadioMode() |
20 | { |
||
21 | |||
22 | } |
||
23 | |||
44 | office | 24 | public abstract string CodeToName(char code); |
15 | office | 25 | |
44 | office | 26 | public abstract char NameToCode(string name); |
15 | office | 27 | |
44 | office | 28 | public static MemoryRadioMode Create(string radio, params object[] param) |
15 | office | 29 | { |
44 | office | 30 | foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) |
15 | office | 31 | { |
44 | office | 32 | foreach (var type in assembly.GetTypes()) |
33 | { |
||
34 | if (typeof(MemoryRadioMode).IsAssignableFrom(type)) |
||
35 | { |
||
36 | var radioAttribute = type.GetCustomAttribute<RadioAttribute>(); |
||
15 | office | 37 | |
44 | office | 38 | if (radioAttribute != null && radioAttribute.Radio == radio) |
39 | { |
||
40 | return (MemoryRadioMode)Activator.CreateInstance(type, param); |
||
41 | } |
||
42 | } |
||
43 | } |
||
15 | office | 44 | } |
45 | |||
44 | office | 46 | return null; |
15 | office | 47 | } |
48 | } |
||
49 | } |