public KmlProperties(KmlProperties p) { Name = p.Name; Desctription = p.Desctription ?? String.Empty; StyleUrl = p.StyleUrl; Open = p.Open; Visibility = p.Visibility; Author = p.Author; Link = p.Link; Address = p.Address; Snippit = p.Snippit; SnippitMaxLines = p.SnippitMaxLines; Region = p.Region; ExtendedData = p.ExtendedData; }
private static void ParseProperties(KmlProperties properties, string name, XmlNode xnode) { switch (name) { case "name": properties.Name = xnode.FirstChild.Value; break; case "description": properties.Desctription = ParseCData(xnode.FirstChild.Value); break; case "styleurl": properties.StyleUrl = xnode.FirstChild.Value; break; case "visibility": if (Boolean.TryParse(xnode.FirstChild.Value, out bool vis)) { properties.Visibility = vis; } break; case "open": if (Boolean.TryParse(xnode.FirstChild.Value, out bool open)) { properties.Open = open; } break; case "author": properties.Author = xnode.FirstChild.Value; break; case "link": properties.Link = xnode.FirstChild.Value; break; case "address": properties.Address = xnode.FirstChild.Value; break; case "snippit": { properties.Snippit = xnode.FirstChild.Value; if (Int32.TryParse(xnode.Attributes["maxLines"]?.FirstChild.Value, out int ml)) { properties.SnippitMaxLines = ml; } break; } case "region": properties.Region = xnode.FirstChild.Value; break; case "extendeddata": properties.ExtendedData = ParseExtendedData(xnode); break; } }
public void WriteProperties(KmlProperties prop) { try { if (prop.Author != null && prop.Author != "") { WriteElementString("atom:author", prop.Author); } if (prop.Link != null && prop.Link != "") { WriteElementString("atom:link", prop.Link); } if (prop.Address != null && prop.Address != "") { WriteElementString("address", prop.Address); } if (prop.Snippit != null && prop.Snippit != "") { WriteStartElement("Snippit"); if (prop.SnippitMaxLines != null) { WriteAttributeString("maxLines", prop.SnippitMaxLines.ToString()); } else { WriteAttributeString("maxLines", "2"); } WriteValue(prop.Snippit); WriteEndElement(); } if (prop.Region != null && prop.Region != "") { WriteElementString("region", prop.Region); } //write extended data if (prop.ExtendedData != null) { if (prop.ExtendedData.DataItems.Count > 0) { WriteStartElement("ExtendedData"); foreach (ExtendedData.Data data in prop.ExtendedData.DataItems) { if (data.Name != null && data.Value != null) { WriteStartElement("Data"); WriteAttributeString("name", data.Name); WriteElementString("value", data.Value); WriteEndElement(); } } WriteEndElement(); } } } catch (Exception ex) { throw new Exception("WriteProperties Error: " + ex.Message); } }