1 class Config 2 { 3 private static Config _instance = null; 4 5 public static Config Instance 6 { 7 get 8 { 9 if (_instance==null) 10 { 11 _instance = new Config() {}; 12 string filepath = AppDomain.CurrentDomain.BaseDirectory + "Config.txt"; 13 if (File.Exists(filepath)) 14 { 15 _instance = File.ReadAllText(filepath, Encoding.UTF8).FromJson<Config>(); 16 } 17 } 18 return _instance; 19 } 20 set { _instance = value; } 21 } 22 23 public void SaveInstance() 24 { 25 string filepath = AppDomain.CurrentDomain.BaseDirectory + "Config.txt"; 26 File.WriteAllText(filepath, _instance.ToJson(), Encoding.UTF8); 27 } 28 29 public string MesServerUrl { get; set; } = "localhost:8080/Mes"; 30 31 public long HangerOneId { get; set; } = 100;// 吊挂产线1的ID 32 33 public long HangerTwoId { get; set; } = 200;// 吊挂产线2的ID 34 35 }