using Newtonsoft.Json; namespace HydroUI { [Serializable] public class Default { static string _filePath = Path.Combine(Directory.GetCurrentDirectory(), @"default.ini"); public NodeViewModel junction; public ReservoirViewModel reservoir; public TankViewModel tank; public MeterViewModel meter; public NozzleViewModel nozzle; public LinkViewModel pipe; public ValveViewModel valve; public RepeaterViewModel repeater; public PumpViewModel pump; public static Default GetfaultINI() { StreamReader sr = new StreamReader(_filePath); string json = sr.ReadToEnd(); sr.Close(); return JsonConvert.DeserializeObject(json); } public void SaveFile() { StreamWriter sw = new StreamWriter(_filePath); sw.WriteLine(JsonConvert.SerializeObject(this)); sw.Close(); } public static Dictionary PreName = new Dictionary() { {MapObjectType.节点,"J" }, {MapObjectType.水库,"R" }, {MapObjectType.水池,"T" }, {MapObjectType.水表,"M" }, {MapObjectType.喷头,"N" }, {MapObjectType.管线,"P" }, {MapObjectType.阀门,"V" }, {MapObjectType.重复器,"Rp" }, {MapObjectType.水泵,"Pump" }, {MapObjectType.阀门点,"Vn" }, }; public static string GetPreString(IBaseViewModel obj) { return PreName[obj.Type]; } } }