public void DeserializeXml() { XmlSerializerProvider.Deserialize(new XmlSerializer(Drivers.GetType()), ref Drivers); XmlSerializerProvider.Deserialize(new XmlSerializer(Routes.GetType()), ref Routes); XmlSerializerProvider.Deserialize(new XmlSerializer(Transports.GetType()), ref Transports); XmlSerializerProvider.Deserialize(new XmlSerializer(Shifts.GetType()), ref Shifts); XmlSerializerProvider.Deserialize(new XmlSerializer(DriverShifts.GetType()), ref DriverShifts); XmlSerializerProvider.Deserialize(new XmlSerializer(TechPassports.GetType()), ref TechPassports); }
// 读取系统配置文件 private bool ReadSystemConfig() { try { XmlSerializerProvider xml = new XmlSerializerProvider(); SystemConfig fc = xml.Deserialize <SystemConfig>(AppDomain.CurrentDomain.BaseDirectory + "\\SystemConfig.xml"); if (string.IsNullOrWhiteSpace(fc.BackupPath) || string.IsNullOrWhiteSpace(fc.CenterIP) || string.IsNullOrWhiteSpace(fc.Port) || string.IsNullOrWhiteSpace(fc.SoundName) || fc.Xrange < 1 || fc.PreiodUnit < 0 || fc.Preiod < 1 || fc.CenterPort < 1 || fc.BaudRate < 1 || fc.BackupPreiod < 1) { LogLib.Log.GetLogger(this).Warn("系统配置文件有空值"); return(false); } systemConfig = fc; comboBoxEdit_Port.Text = systemConfig.Port; textEdit_BaudRate.Text = systemConfig.BaudRate.ToString(); textEdit_Preod.Text = systemConfig.Preiod.ToString(); comboBoxEdit_second.SelectedIndex = systemConfig.PreiodUnit; textEdit_RealTime.Text = systemConfig.Xrange.ToString(); textEdit_Temperature.Text = systemConfig.Temperature.ToString(); textEdit_Volume.Text = systemConfig.Volume.ToString(); textEdit_Molecular.Text = systemConfig.Molecular.ToString(); textEdit_Path.Text = systemConfig.BackupPath; checkEdit_Back.Checked = systemConfig.Isbackup; textEdit_BackupPreiod.Text = systemConfig.BackupPreiod.ToString(); textEdit_CenterIP.Text = systemConfig.CenterIP; textEdit_centerPort.Text = systemConfig.CenterPort.ToString(); checkEdit_autosample.Checked = systemConfig.Isauto; } catch (Exception ex) { LogLib.Log.GetLogger(this).Warn(ex); return(false); } return(true); }