public AOMap(XmlNode aimNode, SlaveTypes sType) { string strRoutineName = "AOMap"; try { slaveType = sType; SetSupportedAttributes();//IMP: Call only after slave types are set... SetSupportedDataTypes(); SetSupportedCommandTypes(); //Parse n store values... Utils.WriteLine(VerboseLevel.DEBUG, "aimNode name: '{0}'", aimNode.Name); if (aimNode.Attributes != null) { //First set the root element value... try { aimnType = (aomType)Enum.Parse(typeof(aomType), aimNode.Name); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", aimNode.Name); } foreach (XmlAttribute item in aimNode.Attributes) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value); try { if (this.GetType().GetProperty(item.Name) != null) //Ajay: 10/08/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); } } Utils.Write(VerboseLevel.DEBUG, "\n"); } else if (aimNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = aimNode.Value; } } catch (Exception ex) { MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public AOMap(string aimName, List <KeyValuePair <string, string> > aimData, SlaveTypes sType) { string strRoutineName = "AOMap"; try { slaveType = sType; SetSupportedAttributes();//IMP: Call only after slave types are set... SetSupportedDataTypes(); SetSupportedCommandTypes(); //First set the root element value... try { aimnType = (aomType)Enum.Parse(typeof(aomType), aimName); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", aimName); } //Parse n store values... if (aimData != null && aimData.Count > 0) { foreach (KeyValuePair <string, string> aimkp in aimData) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", aimkp.Key, aimkp.Value); try { if (this.GetType().GetProperty(aimkp.Key) != null) //Ajay: 10/08/2018 { this.GetType().GetProperty(aimkp.Key).SetValue(this, aimkp.Value); } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", aimkp.Key, aimkp.Value); } } Utils.Write(VerboseLevel.DEBUG, "\n"); } } catch (Exception ex) { MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public AOMap(XmlNode aimNode, SlaveTypes sType) { string strRoutineName = "AOMap"; try { slaveType = sType; SetSupportedAttributes(); //IMP: Call only after slave types are set... SetSupportedDataTypes(); SetSupportedCommandTypes(); if (aimNode.Attributes != null) { //First set the root element value... try { aimnType = (aomType)Enum.Parse(typeof(aomType), aimNode.Name); } catch (System.ArgumentException) { } foreach (XmlAttribute item in aimNode.Attributes) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value); try { if (this.GetType().GetProperty(item.Name) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(item.Name).SetValue(this, item.Value); } } catch (System.NullReferenceException) { } } } else if (aimNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = aimNode.Value; } } catch (Exception ex) { MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }