HamBook – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
3 | office | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | |||
7 | namespace HamBook.Radios.Generic |
||
8 | { |
||
9 | public class ClarifierDirection |
||
10 | { |
||
11 | public ShiftDirection Direction { get; private set; } |
||
12 | |||
13 | public ClarifierDirection(char symbol) |
||
14 | { |
||
15 | Direction = Parse(symbol); |
||
16 | } |
||
17 | |||
18 | private static ShiftDirection Parse(char symbol) |
||
19 | { |
||
20 | switch (symbol) |
||
21 | { |
||
22 | case '+': |
||
23 | return ShiftDirection.PLUS_SHIFT; |
||
24 | case '-': |
||
25 | return ShiftDirection.MINUS_SHIFT; |
||
26 | default: |
||
27 | throw new ArgumentException(); |
||
28 | } |
||
29 | } |
||
30 | |||
31 | private char ToChar() |
||
32 | { |
||
33 | switch (Direction) |
||
34 | { |
||
35 | case ShiftDirection.PLUS_SHIFT: |
||
36 | return '+'; |
||
37 | case ShiftDirection.MINUS_SHIFT: |
||
38 | return '-'; |
||
39 | default: |
||
40 | throw new ArgumentException(); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | public static implicit operator ClarifierDirection(char symbol) |
||
45 | { |
||
46 | return new ClarifierDirection(symbol); |
||
47 | } |
||
48 | |||
49 | public static implicit operator char(ClarifierDirection clarifierDirection) |
||
50 | { |
||
51 | return clarifierDirection.ToChar(); |
||
52 | } |
||
53 | } |
||
54 | } |