|
@@ -0,0 +1,91 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace AwInitilizer
|
|
|
+{
|
|
|
+ public class AppSettingConfig
|
|
|
+ {
|
|
|
+ public static string FirmwareRoot
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if(Instance == null)
|
|
|
+ {
|
|
|
+ Instance = new AppSettingConfig();
|
|
|
+ }
|
|
|
+ return Instance._FirmwareRoot;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static string Language
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (Instance == null)
|
|
|
+ {
|
|
|
+ Instance = new AppSettingConfig();
|
|
|
+ }
|
|
|
+ return Instance._Language;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static string MES
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (Instance == null)
|
|
|
+ {
|
|
|
+ Instance = new AppSettingConfig();
|
|
|
+ }
|
|
|
+ return Instance._MES;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static AppSettingConfig Instance;
|
|
|
+
|
|
|
+ private string _FirmwareRoot, _Language, _MES;
|
|
|
+
|
|
|
+ private static string settingFileName = "config.ini";
|
|
|
+
|
|
|
+ public AppSettingConfig()
|
|
|
+ {
|
|
|
+ if(!File.Exists(settingFileName))
|
|
|
+ {
|
|
|
+ LoadDefaultSetting();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LoadSettingFromDefaultFile();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void LoadSettingFromDefaultFile()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ LoadDefaultSetting();
|
|
|
+
|
|
|
+ var configStr = File.ReadAllText(settingFileName);
|
|
|
+ var config = Newtonsoft.Json.JsonConvert.DeserializeObject<Model.AppSettingConfig>(configStr);
|
|
|
+ _FirmwareRoot = config.FirmwareRoot;
|
|
|
+ _Language = config.Language;
|
|
|
+ _MES = config.MES;
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void LoadDefaultSetting()
|
|
|
+ {
|
|
|
+ _FirmwareRoot = "./Firmware";
|
|
|
+ _Language = "zh-chs";
|
|
|
+ _MES = "shinewave";
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|