示例#1
0
        /// <summary>
        /// 载入数据
        /// </summary>
        /// <returns></returns>
        public static SerialPortDoc LoadObj()
        {
            SerialPortDoc pDoc;
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(SerialPortDoc));
            FileStream    fsReader      = null;

            try
            {
                fsReader = File.OpenRead(@".//Parameter/SerialPortDoc" + ".xml");
                pDoc     = (SerialPortDoc)xmlSerializer.Deserialize(fsReader);
                fsReader.Close();
                pDoc.m_SerialPortDataDictionary = pDoc.m_SerialPortDataList.ToDictionary(p => p.StationName);
            }
            catch (Exception ex)
            {
                if (fsReader != null)
                {
                    fsReader.Close();
                }
                pDoc = new SerialPortDoc();
            }
            return(pDoc);
        }
示例#2
0
 public static void LoadData()
 {
     m_SerilPorts    = new Dictionary <string, ISerialPort>();
     m_SerialPortDoc = SerialPortDoc.LoadObj();
 }