- 키워드 검색, 종목 찾기 추가
- 거부종목, 중복종목, 수동종목 추가
This commit is contained in:
66
Config.cs
Normal file
66
Config.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewsCrawler
|
||||
{
|
||||
static class Config
|
||||
{
|
||||
static Dictionary<string, string> m_Data = new Dictionary<string, string>();
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
m_Data.Add("manual-price", "100000");
|
||||
Load();
|
||||
}
|
||||
|
||||
static void Load()
|
||||
{
|
||||
string strPath = Util.GetConfigPath()+"/config.ini";
|
||||
if(File.Exists(strPath) == false)
|
||||
return;
|
||||
|
||||
m_Data.Clear();
|
||||
|
||||
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;
|
||||
|
||||
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 int GetManualPrice()
|
||||
{
|
||||
int iPrice;
|
||||
int.TryParse(m_Data["manual-price"], out iPrice);
|
||||
return iPrice;
|
||||
}
|
||||
|
||||
public static void SetManualPrice(int iPrice)
|
||||
{
|
||||
m_Data["manual-price"] = iPrice.ToString();
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user