Beispiel #1
0
        /// <summary>
        /// Adds a UN Location Code To The List
        /// </summary>
        /// <param name="unloccode">UN Location Code String</param>
        public void AddLocCodeUN(string unloccode)
        {
            if (string.IsNullOrEmpty(unloccode))
            {
                throw new ArgumentNullException("Value Must Not Be Null or Empty");
            }

            StringGeoTools.CheckLocCodeUN(unloccode);
            this.loccodeUN.Add(unloccode);
        }
Beispiel #2
0
        /// <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");
                }
            }
        }
Beispiel #3
0
        /// <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();
        }