자동 매도 추가
This commit is contained in:
89
Config.cs
Normal file
89
Config.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoSellerNS
|
||||
{
|
||||
static class Config
|
||||
{
|
||||
static Dictionary<string, string> m_Data = new Dictionary<string, string>();
|
||||
|
||||
static Random m_Random = new Random();
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
m_Data.Add("account", "");
|
||||
m_Data.Add("sub-account", "");
|
||||
m_Data.Add("bid-count", "5");
|
||||
|
||||
Load();
|
||||
}
|
||||
|
||||
static void Load()
|
||||
{
|
||||
string strPath = Util.GetConfigPath()+"/config.ini";
|
||||
if(File.Exists(strPath) == false)
|
||||
return;
|
||||
|
||||
string[] aLines = File.ReadAllLines(strPath);
|
||||
foreach(string strLine in aLines)
|
||||
{
|
||||
if(strLine.Trim().Length <= 0)
|
||||
continue;
|
||||
|
||||
string[] aTokens = strLine.Trim().Split('=');
|
||||
if(aTokens.Length < 2)
|
||||
continue;
|
||||
|
||||
if(m_Data.ContainsKey(aTokens[0]) == true)
|
||||
m_Data[aTokens[0]] = aTokens[1];
|
||||
else
|
||||
m_Data.Add(aTokens[0], aTokens[1]);
|
||||
}
|
||||
}
|
||||
|
||||
static void Save()
|
||||
{
|
||||
string strContents = "";
|
||||
foreach(KeyValuePair<string, string> pair in m_Data)
|
||||
strContents += pair.Key + "=" + pair.Value + Environment.NewLine;
|
||||
|
||||
string strPath = Util.GetConfigPath()+"/config.ini";
|
||||
File.WriteAllText(strPath, strContents, new UTF8Encoding(true));
|
||||
}
|
||||
|
||||
public static void SetAccount(string strAccount, string strAccountSub)
|
||||
{
|
||||
m_Data["account"] = strAccount;
|
||||
m_Data["sub-account"] = strAccountSub;
|
||||
Save();
|
||||
}
|
||||
|
||||
public static string GetAccount()
|
||||
{
|
||||
return m_Data["account"];
|
||||
}
|
||||
|
||||
public static string GetSubAccount()
|
||||
{
|
||||
return m_Data["sub-account"];
|
||||
}
|
||||
|
||||
public static void SetBidCount(int iCount)
|
||||
{
|
||||
m_Data["bid-count"] = iCount.ToString();
|
||||
Save();
|
||||
}
|
||||
|
||||
public static int GetBidCount()
|
||||
{
|
||||
int iCount = 0;
|
||||
int.TryParse(m_Data["bid-count"], out iCount);
|
||||
return iCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user