private static List <PageData> LoadPageDataFromXML(Client client, SXL.XDocument xmldoc) { var pagedatas = new List <PageData>(); // LOAD and ANALYZE EACH PAGE int pagenum = 0; var page_els = xmldoc.Root.Elements("page"); foreach (var page_el in page_els) { var node_ids = new HashSet <string>(); var con_ids = new HashSet <string>(); var pagedata = new PageData(); pagedatas.Add(pagedata); pagedata.Errors = new List <BuilderError>(); pagedata.LayoutOptions = new MsaglLayoutOptions(); var renderoptions_el = page_el.Element("renderoptions"); DirectedGraphBuilder.GetRenderOptionsFromXml(renderoptions_el, pagedata.LayoutOptions); pagedata.DirectedGraph = new DirectedGraphLayout(); var shape_els = page_el.Element("shapes").Elements("shape"); var con_els = page_el.Element("connectors").Elements("connector"); pagedata.ShapeInfos = shape_els.Select(e => ShapeInfo.FromXml(client, e)).ToList(); pagedata.ConnectorInfos = con_els.Select(e => ConnectorInfo.FromXml(client, e)).ToList(); client.WriteVerbose("Analyzing shape data for page {0}", pagenum); foreach (var shape_info in pagedata.ShapeInfos) { client.WriteVerbose("shape {0}", shape_info.ID); if (node_ids.Contains(shape_info.ID)) { pagedata.Errors.Add(BuilderError.NodeAlreadyDefined(pagenum, shape_info.ID)); } else { node_ids.Add(shape_info.ID); } } client.WriteVerbose("Analyzing connector data..."); foreach (var con_info in pagedata.ConnectorInfos) { client.WriteVerbose("connector {0}", con_info.ID); if (con_ids.Contains(con_info.ID)) { pagedata.Errors.Add(BuilderError.ConnectorAlreadyDefined(pagenum, con_info.ID)); } else { con_ids.Add(con_info.ID); } if (!node_ids.Contains(con_info.From)) { pagedata.Errors.Add(BuilderError.InvalidFromNode(pagenum, con_info.ID, con_info.From)); } if (!node_ids.Contains(con_info.To)) { pagedata.Errors.Add(BuilderError.InvalidToNode(pagenum, con_info.ID, con_info.To)); } } } return(pagedatas); }