-
Notifications
You must be signed in to change notification settings - Fork 5
/
Config.cs
74 lines (69 loc) · 2.31 KB
/
Config.cs
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
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Windows;
namespace Pancake_Pridction_KNN
{
public static class Config
{
public static AppConfig cfg;
public class AppConfig
{
public AppConfig()
{
faildCount = 0;
betAmountInBNB = 0.01;
AutoBet = false;
Proxy = "";
}
public int faildCount { get; set; }
public double betAmountInBNB { get; set; }
public bool AutoBet { get; set; }
/// <summary>
/// set your http proxy here. like http://127.0.0.1:7890
/// </summary>
public string Proxy { get; set; }
/// <summary>
/// Set your sql server here
/// </summary>
public string DbServerName { get; set; }
public string dbName { get; set; }
public string dbUser { get; set; }
public string dbPassword { get; set; }
public string websocketNode { get; set; }
public string wallletPrivateKey { get; set; }
public string rpc_Endpoint { get; set; }
}
public static void ReadConfig()
{
try
{
var path = AppDomain.CurrentDomain.BaseDirectory + @"\Config\AppConfig.json";
Directory.CreateDirectory(Path.GetDirectoryName(path));
if (!File.Exists(path))
SaveConfig();
var jt = JToken.Parse(File.ReadAllText(path));
cfg = jt.ToObject<AppConfig>();
}
catch (Exception ex)
{
MessageBox.Show($"exception on readconfig!{ex}");
}
}
public static void SaveConfig()
{
try
{
var path = AppDomain.CurrentDomain.BaseDirectory + @"\Config\AppConfig.json";
Directory.CreateDirectory(Path.GetDirectoryName(path));
if (cfg == null) cfg = new AppConfig();
var jt = JToken.FromObject(cfg);
File.WriteAllText(path, jt.ToString());
}
catch (Exception ex)
{
MessageBox.Show($"exception on saveconfig!{ex}");
}
}
}
}