HamBook – Blame information for rev 54

Subversion Repositories:
Rev:
Rev Author Line No. Line
54 office 1 using System;
41 office 2 using System.Collections.Generic;
42 office 3 using System.Reflection;
41 office 4  
5 namespace HamBook.Radios.Generic
6 {
7 public abstract class MemoryBanks
8 {
9 public abstract IEnumerable<string> GetMemoryBanks();
10  
11 public static MemoryBanks Create(string radio)
12 {
42 office 13 foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
54 office 14 foreach (var type in assembly.GetTypes())
15 if (typeof(MemoryBanks).IsAssignableFrom(type))
42 office 16 {
54 office 17 var radioAttribute = type.GetCustomAttribute<RadioAttribute>();
42 office 18  
54 office 19 if (radioAttribute != null && radioAttribute.Radio == radio)
20 return (MemoryBanks)Activator.CreateInstance(type);
42 office 21 }
41 office 22  
43 office 23 return null;
41 office 24 }
25 }
54 office 26 }