HamBook – Diff between revs 41 and 42

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 41 Rev 42
Line 1... Line 1...
1 using HamBook.Properties; 1 using HamBook.Properties;
2 using System; 2 using System;
3 using System.Collections.Generic; 3 using System.Collections.Generic;
4 using System.Linq; 4 using System.Linq;
-   5 using System.Reflection;
5 using System.Text; 6 using System.Text;
6 using System.Threading.Tasks; 7 using System.Threading.Tasks;
Line 7... Line 8...
7   8  
8 namespace HamBook.Radios.Generic 9 namespace HamBook.Radios.Generic
Line 11... Line 12...
11 { 12 {
12 public abstract IEnumerable<string> GetMemoryBanks(); 13 public abstract IEnumerable<string> GetMemoryBanks();
Line 13... Line 14...
13   14  
14 public static MemoryBanks Create(string radio) 15 public static MemoryBanks Create(string radio)
15 { 16 {
16 switch (radio) 17 foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
-   18 {
-   19 foreach (var type in assembly.GetTypes())
-   20 {
-   21 if (typeof(MemoryBanks).IsAssignableFrom(type))
-   22 {
-   23 var radioAttribute = type.GetCustomAttribute<RadioAttribute>();
-   24  
17 { 25 if (radioAttribute != null && radioAttribute.Radio == radio)
18 case "Yaesu FT-891": 26 {
-   27 return (MemoryBanks)Activator.CreateInstance(type);
-   28 }
-   29 }
19 return new Yaesu.FT_891.MemoryBanks(); 30 }
Line 20... Line 31...
20 } 31 }
21   32  
22 throw new ArgumentException(Resources.Unknown_radio_type); 33 throw new ArgumentException(Resources.Unknown_radio_type, radio);
23 } 34 }