Exemplo n.º 1
0
        public void Save(SyncMachineConfigurationModel model)
        {
            var text = JsonConvert.SerializeObject(model, Formatting.Indented);

            if (File.Exists(_cfgFile))
            {
                File.Copy(_cfgFile, _cfgFileBackup, true);
            }
            File.WriteAllText(_cfgFile, text);
            ConsoleLogger.Log("[syncmachine] configuration saved");
        }
Exemplo n.º 2
0
 public SyncMachineConfiguration()
 {
     IoDir.CreateDirectory(Parameter.AntdCfgServices);
     if (!File.Exists(_cfgFile))
     {
         _serviceModel = new SyncMachineConfigurationModel();
     }
     else
     {
         try {
             var text = File.ReadAllText(_cfgFile);
             var obj  = JsonConvert.DeserializeObject <SyncMachineConfigurationModel>(text);
             _serviceModel = obj;
         }
         catch (Exception) {
             _serviceModel = new SyncMachineConfigurationModel();
         }
     }
 }