/// <exception cref="XMLStreamException"></exception> private Response readResponse(XmlReader xmlReader) { Response response = new Response(); bool finished = false; while(!finished && xmlReader.MoveToNextAttribute()) { //int Event = xmlReader.next(); string name = XmlUtils.getElementQualifiedName(xmlReader, namespaces); switch(xmlReader.NodeType) { case XmlNodeType.Element: if("config:action".Equals(name)) { response.setAction(xmlReader.ReadString().Trim()); } else if("config:interval".Equals(name)) { Interval interval = new Interval(); // interval.setUnit(xmlReader.getAttributeValue(null, "unit").Trim()); interval.setUnit(xmlReader.GetAttribute("unit", null).Trim()); /* * getAttributeValue takes as parameters namespaceURI and localName * GetAttribute takes as parameters localName and namespaceURI * * Migrator's note. */ interval.setDuration(Int32.Parse(xmlReader.ReadString().Trim())); response.setInterval(interval); } else { /** unexpected start element **/ } break; case XmlNodeType.EndElement: if("config:response".Equals(name)) { finished = true; } else { /** unexpected end element **/ } break; default: /** unused xml element - nothing to do **/ break; } } return response; }
/// <exception cref="XMLStreamException"></exception> private Threshold readThreshold(XmlReader xmlReader) { Threshold threshold = new Threshold(); bool finished = false; while(!finished && xmlReader.MoveToNextAttribute()) { //int Event = xmlReader.next(); string name = XmlUtils.getElementQualifiedName(xmlReader, namespaces); switch(xmlReader.NodeType) { case XmlNodeType.Element: if("config:count".Equals(name)) { threshold.setCount(Int32.Parse(xmlReader.ReadString().Trim())); } else if("config:interval".Equals(name)) { Interval interval = new Interval(); //interval.setUnit(xmlReader.getAttributeValue(null, "unit").Trim()); interval.setUnit(xmlReader.GetAttribute("unit", null).Trim()); interval.setDuration(Int32.Parse(xmlReader.ReadString().Trim())); threshold.setInterval(interval); } else { /** unexpected start element **/ } break; case XmlNodeType.EndElement: if("config:threshold".Equals(name)) { finished = true; } else { /** unexpected end element **/ } break; default: /** unused xml element - nothing to do **/ break; } } return threshold; }