-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCurrency.cs
More file actions
79 lines (70 loc) · 2.08 KB
/
Currency.cs
File metadata and controls
79 lines (70 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#region license
// Please read and agree to license.md contents before using this SDK.
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mcxNOW
{
public sealed class Currency
{
public string Code { get; private set; }
public string Name { get; private set; }
private int Value { get; set; }
public static readonly Currency MNC = new Currency(1, "MNC", "MinCoin");
public static readonly Currency LTC = new Currency(2, "LTC", "Litecoin");
public static readonly Currency SC = new Currency(3, "SC", "SolidCoin");
public static readonly Currency DVC = new Currency(4, "DVC", "Devcoin");
public static readonly Currency WDC = new Currency(4, "WDC", "WorldCoin");
public static readonly Currency BTC = new Currency(5, "BTC", "Bitcoin");
/**
* Return list of all currencies except BTC (it is exchange base currency)
*/
public static List<Currency> GetAllTraded()
{
return new List<Currency>
{
MNC,
LTC,
SC,
DVC,
WDC,
};
}
public static List<Currency> GetAll()
{
return new List<Currency>
{
BTC,
MNC,
LTC,
SC,
DVC,
WDC,
};
}
private Currency(int value, String code, String name)
{
Code = code;
Name = name;
Value = value;
}
public override String ToString()
{
return Code;
}
public static Currency FromString(string value)
{
foreach (Currency currency in GetAll())
{
if (currency.Code == value || currency.Name == value)
{
return currency;
}
}
throw new Exception("Unknown currency");
}
}
}