/// <summary> /// Reads an XML Object From An Existing DOM /// </summary> /// <param name="rootNode">Node Containing the Root Object Element</param> internal void ReadXML(XmlNode rootNode) { NameValueType namevaluetmp; char[] delimSpace = { ' ' }; char[] delimComma = { ',' }; foreach (XmlNode node in rootNode.ChildNodes) { if (string.IsNullOrEmpty(node.InnerText)) { continue; } switch (node.LocalName) { case "areaDesc": this.areaDesc = node.InnerText; break; case "polygon": string polygonString = node.InnerText; StringGeoTools.CheckPolygon(polygonString); this.polygon.Add(polygonString); break; case "circle": string circlePt = node.InnerText; StringGeoTools.CheckCircle(circlePt); this.circle.Add(circlePt); break; case "geocode": namevaluetmp = new NameValueType(); namevaluetmp.ReadXML(node); this.geoCode.Add(namevaluetmp); break; case "altitude": StringGeoTools.CheckDecimal(decimal.Parse(node.InnerText)); this.altitude = decimal.Parse(node.InnerText); break; case "ceiling": StringGeoTools.CheckDecimal(decimal.Parse(node.InnerText)); this.ceiling = decimal.Parse(node.InnerText); break; case "#comment": break; default: throw new FormatException("Invalid value: " + node.InnerText + " found in Area Type"); } } }
/// <summary> /// Reads an XML Object From An Existing DOM /// </summary> /// <param name="rootNode">Node Containing the Root Object Element</param> /// <param name="sentDateTime">DateTime From Parent for Default Value</param> internal void ReadXML(XmlNode rootNode, DateTime sentDateTime) { ResourceType resourcetypetmp; AreaType areatypetmp; NameValueType eventcodetmp, parametertmp; this.sent = sentDateTime; foreach (XmlNode node in rootNode.ChildNodes) { if (string.IsNullOrEmpty(node.InnerText)) { continue; } if (node.InnerText != string.Empty) { switch (node.LocalName) { case "language": this.language = node.InnerText; break; case "category": this.category.Add((CategoryType)Enum.Parse(typeof(CategoryType), node.InnerText)); break; case "event": this.eventType = node.InnerText; break; case "responseType": this.responseType.Add((ResponseType)Enum.Parse(typeof(ResponseType), node.InnerText)); break; case "urgency": this.urgency = (UrgencyType)Enum.Parse(typeof(UrgencyType), node.InnerText); break; case "severity": this.severity = (SeverityType)Enum.Parse(typeof(SeverityType), node.InnerText); break; case "certainty": this.certainty = (CertaintyType)Enum.Parse(typeof(CertaintyType), node.InnerText); break; case "audience": this.audience = node.InnerText; break; case "eventCode": eventcodetmp = new NameValueType(); eventcodetmp.ReadXML(node); this.eventCode.Add(eventcodetmp); break; case "effective": this.effective = DateTime.Parse(node.InnerText); if (this.effective.Kind == DateTimeKind.Unspecified) { this.effective = DateTime.MinValue; throw new ArgumentException("TimeZone Information Must Be Specified"); } this.effective = this.effective.ToUniversalTime(); break; case "onset": this.infoOnSet = DateTime.Parse(node.InnerText); if (this.infoOnSet.Kind == DateTimeKind.Unspecified) { this.infoOnSet = DateTime.MinValue; throw new ArgumentException("TimeZone Information Must Be Specified"); } this.infoOnSet = this.infoOnSet.ToUniversalTime(); break; case "expires": this.expires = DateTime.Parse(node.InnerText); if (this.expires.Kind == DateTimeKind.Unspecified) { this.expires = DateTime.MinValue; throw new ArgumentException("TimeZone Information Must Be Specified"); } this.expires = this.expires.ToUniversalTime(); break; case "senderName": this.senderName = node.InnerText; break; case "headline": this.headline = node.InnerText; break; case "description": this.description = node.InnerText; break; case "instruction": this.instruction = node.InnerText; break; case "web": this.web = new Uri(node.InnerText); break; case "contact": this.contact = node.InnerText; break; case "parameter": parametertmp = new NameValueType(); parametertmp.ReadXML(node); this.parameter.Add(parametertmp); break; case "resource": resourcetypetmp = new ResourceType(); resourcetypetmp.ReadXML(node); this.resource.Add(resourcetypetmp); break; case "area": areatypetmp = new AreaType(); areatypetmp.ReadXML(node); this.area.Add(areatypetmp); break; case "#comment": break; default: throw new FormatException("Invalid value: " + node.Name + " found in Info Type"); } } } }