HamBook – Blame information for rev 16

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