HamBook – Blame information for rev 54

Subversion Repositories:
Rev:
Rev Author Line No. Line
3 office 1 using System;
2  
3 namespace HamBook.Radios.Generic
4 {
15 office 5 public class RadioStorage
3 office 6 {
15 office 7 public RadioStorage(string storage)
8 {
9 Storage = Parse(storage);
10 }
11  
12 public RadioStorage(int storage)
13 {
14 Storage = Parse(storage);
15 }
16  
54 office 17 public int Storage { get; }
18  
15 office 19 public static bool TryParse(string storage, out RadioStorage radioMode)
20 {
21 switch (storage)
22 {
23 case "VFO":
24 case "Memory":
25 case "Memory Tune":
26 case "PMS":
27 radioMode = new RadioStorage(storage);
28 return true;
29 default:
30 radioMode = null;
31 return false;
32 }
33 }
34  
35 public static bool TryParse(int storage, out RadioStorage radioMode)
36 {
37 switch (storage)
38 {
39 case 0:
40 case 1:
41 case 2:
42 case 5:
43 radioMode = new RadioStorage(storage);
44 return true;
45 default:
46 radioMode = null;
47 return false;
48 }
49 }
50  
51 private int Parse(string storage)
52 {
53 switch (storage)
54 {
55 case "VFO":
56 return 0;
57 case "Memory":
58 return 1;
59 case "Memory Tune":
60 return 2;
61 case "PMS":
62 return 5;
63 default:
64 throw new ArgumentException();
65 }
66 }
67  
68 private int Parse(int storage)
69 {
70 switch (storage)
71 {
72 case 0:
73 case 1:
74 case 2:
75 case 5:
76 return storage;
77 default:
78 throw new ArgumentException();
79 }
80 }
81  
82 public static implicit operator RadioStorage(string storage)
83 {
84 return new RadioStorage(storage);
85 }
86  
87 public static implicit operator string(RadioStorage radioStorage)
88 {
89 switch (radioStorage.Storage)
90 {
91 case 0:
92 return "VFO";
93 case 1:
94 return "Memory";
95 case 2:
96 return "Memory Tune";
97 case 5:
98 return "PMS";
99 default:
100 throw new ArgumentException();
101 }
102 }
103  
104 public static implicit operator RadioStorage(int storage)
105 {
106 return new RadioStorage(storage);
107 }
108  
109 public static implicit operator int(RadioStorage radioMode)
110 {
111 return radioMode.Storage;
112 }
3 office 113 }
54 office 114 }