public UFSMS(XmlNode sNode, TreeNode tn) { string strRoutineName = "UFSMS"; try { SetSupportedAttributes(); if (sNode.Attributes != null) { //First set the root element value... try { UfsmsType = (UFSMSType)Enum.Parse(typeof(UFSMSType), sNode.Name); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", sNode.Name); } if (sNode.HasChildNodes) { //for (int iChild = 0; i < sNode.ChildNodes.Count; iChild++) //{ if (sNode.ChildNodes[iChild].Name == "SMSUser") { foreach (XmlAttribute xmlattribute in sNode.ChildNodes[iChild].Attributes) { try { if (this.GetType().GetProperty(xmlattribute.Name) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(xmlattribute.Name).SetValue(this, xmlattribute.Value); } } catch (System.NullReferenceException) { } } iChild++; } } //} Utils.Write(VerboseLevel.DEBUG, "\n"); } else if (sNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = sNode.Value; } } catch (Exception ex) { MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } //Not Used: uciec.lblMain.Text += slaveNum; }
public UFSMS(string UfsmsName, List <KeyValuePair <string, string> > s101Data, TreeNode tn) { string strRoutineName = "UFSMS"; try { SetSupportedAttributes(); try { UfsmsType = (UFSMSType)Enum.Parse(typeof(UFSMSType), UfsmsName); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", UfsmsName); } //Parse n store values... if (s101Data != null && s101Data.Count > 0) { foreach (KeyValuePair <string, string> s104kp in s101Data) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", s104kp.Key, s104kp.Value); try { if (this.GetType().GetProperty(s104kp.Key) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(s104kp.Key).SetValue(this, s104kp.Value); } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value:{1}", s104kp.Key, s104kp.Value); } } Utils.Write(VerboseLevel.DEBUG, "\n"); } } catch (Exception ex) { MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }