HamBook – Blame information for rev 54

Subversion Repositories:
Rev:
Rev Author Line No. Line
54 office 1 using System;
43 office 2 using System.Reflection;
46 office 3 using System.Xml.Serialization;
1 office 4  
5 namespace HamBook.Radios.Generic
6 {
46 office 7 [XmlRoot(Namespace = "Generic")]
43 office 8 public abstract class RadioMode
1 office 9 {
44 office 10 public abstract char Code { get; }
3 office 11  
44 office 12 public abstract string Name { get; }
3 office 13  
44 office 14 public abstract string CodeToName(char code);
3 office 15  
44 office 16 public abstract char NameToCode(string name);
3 office 17  
43 office 18 public static RadioMode Create(string radio, params object[] param)
3 office 19 {
43 office 20 foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
54 office 21 foreach (var type in assembly.GetTypes())
22 if (typeof(RadioMode).IsAssignableFrom(type))
43 office 23 {
54 office 24 var radioAttribute = type.GetCustomAttribute<RadioAttribute>();
3 office 25  
54 office 26 if (radioAttribute != null && radioAttribute.Radio == radio)
27 return (RadioMode)Activator.CreateInstance(type, param);
43 office 28 }
3 office 29  
43 office 30 return null;
3 office 31 }
1 office 32 }
54 office 33 }