public Style(XElement node, string @namespace) { var element = node.Element(XName.Get("Name", @namespace)); if (element == null) throw WmsParsingException.ElementNotFound("Name"); Name = element.Value; element = node.Element(XName.Get("Title", @namespace)); if (element == null) throw WmsParsingException.ElementNotFound("Title"); Title = element.Value; element = node.Element(XName.Get("Abstract", @namespace)); if (element != null) Abstract = element.Value; foreach (var el in node.Elements(XName.Get("LegendURL", @namespace))) LegendURL.Add(new LegendURL(el, @namespace)); element = node.Element(XName.Get("StyleSheetURL", @namespace)); if (element != null) StyleSheetURL = new StyleSheetURL(element, @namespace); element = node.Element(XName.Get("StyleURL", @namespace)); if (element != null) StyleURL = new StyleURL(element, @namespace); }
public override void ReadXml(XmlReader reader) { reader.MoveToContent(); if (reader.IsEmptyElement) { reader.Read(); return; } Name = Title = Abstract = null; LegendURL.Clear(); _styleSheetURLField = null; _styleURLField = null; while (!reader.EOF) { if (reader.IsStartElement()) { switch (reader.LocalName) { case "Name": Name = reader.ReadElementContentAsString(); break; case "Title": Title = reader.ReadElementContentAsString(); break; case "Abstract": Abstract = reader.ReadElementContentAsString(); break; case "LegendURL": var legendUrl = new LegendURL(); legendUrl.ReadXml(reader); LegendURL.Add(legendUrl); break; case "StyleSheetURL": _styleSheetURLField = new StyleSheetURL(); _styleSheetURLField.ReadXml(reader); break; case "": _styleURLField = new StyleURL(); _styleURLField.ReadXml(reader); break; default: reader.Skip(); break; } } else { reader.Read(); } } }
public Style(XElement node, string @namespace) { var element = node.Element(XName.Get("Name", @namespace)); if (element == null) { throw WmsParsingException.ElementNotFound("Name"); } Name = element.Value; element = node.Element(XName.Get("Title", @namespace)); if (element == null) { throw WmsParsingException.ElementNotFound("Title"); } Title = element.Value; element = node.Element(XName.Get("Abstract", @namespace)); if (element != null) { Abstract = element.Value; } foreach (var el in node.Elements(XName.Get("LegendURL", @namespace))) { LegendURL.Add(new LegendURL(el, @namespace)); } element = node.Element(XName.Get("StyleSheetURL", @namespace)); if (element != null) { StyleSheetURL = new StyleSheetURL(element, @namespace); } element = node.Element(XName.Get("StyleURL", @namespace)); if (element != null) { StyleURL = new StyleURL(element, @namespace); } }