private static void _SaveStops( XmlWriter writer, Route route, ICollection <Stop> stops, ICollection <string> orderPropertiesToExport, Project project, AddressField[] addressFields) { Debug.Assert(route != null); var sortedStops = new List <Stop>(stops); CommonHelpers.SortBySequence(sortedStops); var orderPropertiesTitlesToExport = new List <string>(); var names = new List <string>(Order.GetPropertyNames(project.CapacitiesInfo, project.OrderCustomPropertiesInfo, addressFields)); var titles = new List <string>(Order.GetPropertyTitles(project.CapacitiesInfo, project.OrderCustomPropertiesInfo, addressFields)); foreach (string name in orderPropertiesToExport) { int index = names.IndexOf(name); string title = titles[index]; orderPropertiesTitlesToExport.Add(title); } var routeStops = CommonHelpers.GetSortedStops(route); writer.WriteStartElement(STOPS_NODE_NAME); foreach (Stop stop in sortedStops) { string name = _GetStopName(stop, routeStops); var mapLocation = stop.MapLocation; if (!mapLocation.HasValue) { if (stop.StopType != StopType.Lunch) { throw new InvalidOperationException( Properties.Messages.Error_GrfExporterNoLocationForStop); // exception } var currentIndex = stop.SequenceNumber - 1; var stopWithLocation = SolveHelper.GetActualLunchStop(routeStops, currentIndex); if (!stopWithLocation.MapLocation.HasValue) { throw new InvalidOperationException( Properties.Messages.Error_GrfExporterNoLocationForStop); // exception } mapLocation = stopWithLocation.MapLocation.Value; } writer.WriteStartElement(STOP_NODE_NAME); writer.WriteAttributeString(ENABLED_ATTR_NAME, TRUE_VALUE); string comments = _GetComments(stop, orderPropertiesToExport, orderPropertiesTitlesToExport); _SaveLocationNode(writer, mapLocation.Value, name, comments); writer.WriteStartElement(DURATION_NODE_NAME); double duration = stop.TimeAtStop * 60; writer.WriteValue(duration.ToString(DOUBLE_FORMAT, NumberFormatInfo.InvariantInfo)); writer.WriteEndElement(); writer.WriteEndElement(); } writer.WriteEndElement(); }