/// <summary> /// 初始化配置 /// </summary> public static void Init(Action action) { //初始配置信息 var Configuration = new ConfigurationBuilder() .AddJsonFile($"{Path}\\appsetting.json") .Build(); ThreadNum = int.Parse(Configuration.GetSection("ThreadNum").Value); Proxy = Configuration.GetSection("Proxy").Value; RegisterCode = Configuration.GetSection("RegisterCode").Value; Configuration.GetSection("ThreadNum").Value = ThreadNum.ToString(); //获取价格计算函数 { string path = Path + "\\Config\\Price.js"; if (File.Exists(path)) { StreamReader sr = File.OpenText(path); StringBuilder jsonArrayText_tmp = new StringBuilder(); string txt = sr.ReadToEnd().ToString(); sr.Close(); try { PriceFunction = txt; } catch { } } } //获取商品详情 { string path = Path + "\\Config\\ProductDesc.txt"; if (File.Exists(path)) { StreamReader sr = File.OpenText(path); StringBuilder jsonArrayText_tmp = new StringBuilder(); string txt = sr.ReadToEnd().ToString(); sr.Close(); try { ProductDesc = txt; } catch { } } } //获取关键词 { string path = Path + "\\Config\\key.txt"; if (File.Exists(path)) { StreamReader sr = File.OpenText(path); StringBuilder jsonArrayText_tmp = new StringBuilder(); string line = ""; while ((line = sr.ReadLine()) != null) { if (line.Trim() != "") { Key.Insert(0, line); } } } } //获取分类 { string path = Path + "\\Config\\ProductTypes.txt"; if (File.Exists(path)) { StreamReader sr = File.OpenText(path); StringBuilder jsonArrayText_tmp = new StringBuilder(); string line = ""; while ((line = sr.ReadLine()) != null) { if (line.Trim() != "") { ProductTypes.Insert(0, line); } } } } action?.Invoke(); }