/// <summary> /// Reads the next NVG element from the stream. /// </summary> /// <returns>The next NVG element or <code>null</code> when there are no more NVG elements.</returns> public INvgElement ReadNextElement() { NvgElementPosition elementPosition = null; INvgElement element = null; while (_xmlTextReader.Read()) { switch (_xmlTextReader.NodeType) { case XmlNodeType.Element: var startTag = new NvgElementTag(_xmlTextReader.LocalName); if (startTag.IsNvgTag) { // Read the NVG element element = new NvgElement(); element.ConstructFromReader(_xmlTextReader); elementPosition = CreateElementPosition(element, startTag, elementPosition); } else if (startTag.IsGroupTag) { // Read the NVG group element element = new NvgGroupElement(); element.ConstructFromReader(_xmlTextReader); elementPosition = CreateElementPosition(element, startTag, elementPosition); } else if (startTag.IsPointTag) { // Read the NVG point element element = new NvgPointElement(); element.ConstructFromReader(_xmlTextReader); elementPosition = CreateElementPosition(element, startTag, elementPosition); } break; case XmlNodeType.EndElement: var endTag = new NvgElementTag(_xmlTextReader.LocalName); // Add children and reset the position to the matching start tag elementPosition = AddChildren(elementPosition, endTag); if (null != elementPosition) { // Reset the current element to the start tag element = elementPosition.Element; } if (endTag.IsNvgTag) { return(element); } break; } } return(null); }
private static Message CreateMessage(NvgPointElement pointElement) { var messageProperties = new Dictionary <string, string>(); messageProperties.Add(@"_type", @"position_report"); messageProperties.Add(@"_action", @"update"); messageProperties.Add(@"_id", pointElement.Id); messageProperties.Add(@"_control_points", string.Format(CultureInfo.InvariantCulture, @"{0},{1}", pointElement.X, pointElement.Y)); messageProperties.Add(@"_wkid", @"4326"); messageProperties.Add(@"sic", pointElement.SymbolCode); messageProperties.Add(@"uniquedesignation", pointElement.Label); return(new Message(messageProperties)); }
private static bool TryProcessMessage(NvgPointElement nvgPointElement, MessageLayer messageLayer) { if (null != nvgPointElement) { if (!nvgPointElement.IsEmpty) { var message = CreateMessage(nvgPointElement); if (messageLayer.ProcessMessage(message)) { return(true); } } } return(false); }