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