/// <summary> /// Adds a SubDivision To The List /// </summary> /// <param name="subdivisionin">SubDivision String</param> public void AddSubDivision(string subdivisionin) { if (string.IsNullOrEmpty(subdivisionin)) { throw new ArgumentException("Input Value Can't Be Null or Empty!"); } StringGeoTools.CheckSubdivision(subdivisionin); this.subdivision.Add(subdivisionin); }
/// <summary> /// Reads This IComposable Message From An Existing XML Document /// </summary> /// <param name="rootnode">Node That Points to the TargetArea Element</param> public void ReadXML(XmlNode rootnode) { if (rootnode == (XmlNode)null) { throw new ArgumentNullException("RootNode"); } foreach (XmlNode node in rootnode.ChildNodes) { if (string.IsNullOrEmpty(node.InnerText)) { continue; } switch (node.LocalName) { case "circle": StringGeoTools.CheckCircle(node.InnerText); this.circle.Add(node.InnerText); break; case "polygon": StringGeoTools.CheckPolygon(node.InnerText); this.polygon.Add(node.InnerText); break; case "country": StringGeoTools.CheckCountry(node.InnerText); this.country.Add(node.InnerText); break; case "subdivision": StringGeoTools.CheckSubdivision(node.InnerText); this.subdivision.Add(node.InnerText); break; case "locCodeUN": StringGeoTools.CheckLocCodeUN(node.InnerText); this.loccodeUN.Add(node.InnerText); break; case "#comment": break; default: throw new FormatException("Invalid value: " + node.InnerText + " found in TargetArea Type"); } } }
/// <summary> /// Writes This IComposable Message Into An Existing XML Document /// </summary> /// <param name="xwriter">Existing XML Document Writer</param> public void WriteXML(XmlWriter xwriter) { if (this.circle.Count == 0 && this.polygon.Count == 0 && this.country.Count == 0 && this.subdivision.Count == 0 && this.loccodeUN.Count == 0) { throw new ArgumentNullException("All Elements can't be null"); } xwriter.WriteStartElement("targetArea"); foreach (string circle in this.circle) { StringGeoTools.CheckCircle(circle); xwriter.WriteElementString("circle", circle); } foreach (string polygon in this.polygon) { StringGeoTools.CheckPolygon(polygon); xwriter.WriteElementString("polygon", polygon); } foreach (string country in this.country) { StringGeoTools.CheckCountry(country); xwriter.WriteElementString("country", country); } foreach (string subdivision in this.subdivision) { StringGeoTools.CheckSubdivision(subdivision); xwriter.WriteElementString("subdivision", subdivision); } foreach (string loccodeun in this.loccodeUN) { StringGeoTools.CheckLocCodeUN(loccodeun); xwriter.WriteElementString("locCodeUN", loccodeun); } xwriter.WriteEndElement(); }