public DOMap(string domName, List <KeyValuePair <string, string> > domData, SlaveTypes sType) { slaveType = sType; SetSupportedAttributes();//IMP: Call only after slave types are set... SetSupportedDataTypes(); SetSupportedCommandTypes(); SetSupportedEventClass(); SetSupportedEventVariation(); SetSupportedVariation(); //First set the root element value... try { domnType = (domType)Enum.Parse(typeof(domType), domName); } catch (System.ArgumentException) { } //Parse n store values... if (domData != null && domData.Count > 0) { foreach (KeyValuePair <string, string> domkp in domData) { try { if (this.GetType().GetProperty(domkp.Key) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(domkp.Key).SetValue(this, domkp.Value); } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", domkp.Key, domkp.Value); } } } }
public DOMap(XmlNode domNode, SlaveTypes sType) { slaveType = sType; SetSupportedAttributes();//IMP: Call only after slave types are set... SetSupportedDataTypes(); SetSupportedCommandTypes(); SetSupportedEventClass(); SetSupportedEventVariation(); SetSupportedVariation(); if (domNode.Attributes != null) { //First set the root element value... try { domnType = (domType)Enum.Parse(typeof(domType), domNode.Name); } catch (System.ArgumentException) { } if ((slaveType == SlaveTypes.GRAPHICALDISPLAYSLAVE) || (slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.UNKNOWN) || (slaveType == SlaveTypes.SPORTSLAVE) || (slaveType == SlaveTypes.MQTTSLAVE) || (slaveType == SlaveTypes.SMSSLAVE) || (slaveType == SlaveTypes.DNP3SLAVE)) { foreach (XmlAttribute item in domNode.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) { } } } //Namrata: 07/11/2017 // If slaveType Type is IEC61850Server if (slaveType == SlaveTypes.IEC61850Server) { if (domNode.Name == "DO") { foreach (XmlAttribute xmlattribute in domNode.Attributes) { try { if (xmlattribute.Name == "ReportingIndex") { iec61850reportingindex = domNode.Attributes[1].Value; } else { if (this.GetType().GetProperty(xmlattribute.Name) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(xmlattribute.Name).SetValue(this, xmlattribute.Value); } } } catch (System.NullReferenceException) { } } } } } else if (domNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = domNode.Value; } }
public DOMap(XmlNode domNode, SlaveTypes sType) { slaveType = sType; SetSupportedAttributes();//IMP: Call only after slave types are set... SetSupportedDataTypes(); SetSupportedCommandTypes(); //Parse n store values... Utils.WriteLine(VerboseLevel.DEBUG, "domNode name: '{0}'", domNode.Name); if (domNode.Attributes != null) { //First set the root element value... try { domnType = (domType)Enum.Parse(typeof(domType), domNode.Name); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", domNode.Name); } if ((slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.UNKNOWN)) { foreach (XmlAttribute item in domNode.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); } } } //Namrata: 07/11/2017 // If slaveType Type is IEC61850Server if (slaveType == SlaveTypes.IEC61850Server) { if (domNode.Name == "DO") { foreach (XmlAttribute xmlattribute in domNode.Attributes) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", xmlattribute.Name, xmlattribute.Value); try { if (xmlattribute.Name == "ReportingIndex") { iec61850reportingindex = domNode.Attributes[1].Value; } else { if (this.GetType().GetProperty(xmlattribute.Name) != null) //Ajay: 10/08/2018 { this.GetType().GetProperty(xmlattribute.Name).SetValue(this, xmlattribute.Value); } } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "DI: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", xmlattribute.Name, xmlattribute.Value); } } } } Utils.Write(VerboseLevel.DEBUG, "\n"); } else if (domNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = domNode.Value; } }