HamBook – Blame information for rev 43
?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; |
||
9 | |||
10 | namespace HamBook.Radios.Generic |
||
11 | { |
||
43 | office | 12 | public abstract class RadioMode |
1 | office | 13 | { |
43 | office | 14 | public abstract char Mode { get; } |
3 | office | 15 | |
43 | office | 16 | public abstract RadioMode AsRadioMode(string mode); |
3 | office | 17 | |
43 | office | 18 | public abstract string AsString(RadioMode radioMode); |
3 | office | 19 | |
43 | office | 20 | public abstract RadioMode AsRadioMode(char mode); |
21 | |||
22 | public abstract char AsChar(RadioMode radioMode); |
||
3 | office | 23 | |
43 | office | 24 | public abstract bool TryParse(string mode, out RadioMode radioMode); |
3 | office | 25 | |
43 | office | 26 | public abstract bool TryParse(char mode, out RadioMode radioMode); |
3 | office | 27 | |
43 | office | 28 | public static RadioMode Create(string radio, params object[] param) |
3 | office | 29 | { |
43 | office | 30 | foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) |
3 | office | 31 | { |
43 | office | 32 | foreach (var type in assembly.GetTypes()) |
33 | { |
||
34 | if (typeof(RadioMode).IsAssignableFrom(type)) |
||
35 | { |
||
36 | var radioAttribute = type.GetCustomAttribute<RadioAttribute>(); |
||
3 | office | 37 | |
43 | office | 38 | if (radioAttribute != null && radioAttribute.Radio == radio) |
39 | { |
||
40 | return (RadioMode)Activator.CreateInstance(type, param); |
||
41 | } |
||
42 | } |
||
43 | } |
||
3 | office | 44 | } |
45 | |||
43 | office | 46 | return null; |
3 | office | 47 | } |
1 | office | 48 | } |
49 | } |