Exemple #1
0
 /// <summary>
 /// 传入系统中保存的 XML 配置数据初始化该系统配置对象。
 /// </summary>
 /// <param name="deviceConfig"></param>
 public void SetConfig(System.Xml.XmlNode deviceConfig)
 {
     //deviceConfig.Name == 下面GetConfig(System.Xml.XmlDocument xmlDoc)中的根Node的Name"string.Format("{0}_List", typeof(T).ToString())"
     if (this._L_t == null)
     {
         this._L_t = new List <T>();
     }
     else if (this._L_t.Count > 0)
     {
         this._L_t.Clear();
     }
     if (this._pc_t == null)
     {
         this._pc_t = new ParametersConversion <T>();
     }
     foreach (XmlNode xn in deviceConfig.ChildNodes)
     {
         if (xn.ChildNodes.Count > 0)
         {
             //xn.Name == this._pc_t.GetConfig(System.Xml.XmlDocument xmlDoc)中的根Node的Name"typeof(T).ToString()"
             this._pc_t.SetConfig(xn);
             this._L_t.Add(this._pc_t.Paras);
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// 获取当前系统配置对象 XML 形式的配置数据。
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <returns></returns>
        public System.Xml.XmlNode GetConfig(System.Xml.XmlDocument xmlDoc)
        {
            XmlNode xnRoot = xmlDoc.CreateElement(string.Format("{0}_List", typeof(T).ToString()));
            XmlNode xnChild;

            if (this._pc_t == null)
            {
                this._pc_t = new ParametersConversion <T>();
            }
            if (this._L_t != null && this._L_t.Count > 0)
            {
                foreach (T t in this._L_t)
                {
                    this._pc_t.Paras = t;
                    xnChild          = this._pc_t.GetConfig(xmlDoc);
                    xnRoot.AppendChild(xnChild);
                }
            }
            return(xnRoot);
        }