public SLDSettings(XmlNode sNode, TreeNode tn) { string strRoutineName = "SLDSettings"; try { if (sNode.Attributes != null) { try { SLDType = (SLDSettingsType)Enum.Parse(typeof(SLDSettingsType), sNode.Name); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", sNode.Name); } foreach (XmlAttribute item in sNode.Attributes) { try { if (this.GetType().GetProperty(item.Name) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(item.Name).SetValue(this, item.Value); } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value:{1}", item.Name, item.Value); } } } 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); } }
public SLDSettings(string smsUserName, List <KeyValuePair <string, string> > SLDSettingsData, TreeNode tn, int mNo) { string strRoutineName = "SLDSettings"; try { try { SLDType = (SLDSettingsType)Enum.Parse(typeof(SLDSettingsType), smsUserName); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", smsUserName); } if (SLDSettingsData != null && SLDSettingsData.Count > 0) { foreach (KeyValuePair <string, string> lpfilekp in SLDSettingsData) { try { if (this.GetType().GetProperty(lpfilekp.Key) != null) { this.GetType().GetProperty(lpfilekp.Key).SetValue(this, lpfilekp.Value); } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "LPFile: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", lpfilekp.Key, lpfilekp.Value); } } } } catch (Exception ex) { MessageBox.Show(strRoutineName + ": " + "Error:" + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }