/// <summary> /// Reads an XML Object From An Existing DOM /// </summary> /// <param name="rootNode">Node Containing the root Object element</param> public void ReadXML(XmlNode rootNode) { ContactInformationType contactinfotmp; FundingType fundtmp; IncidentInformationType incidenttemp; ResourceInformationType restmp; if (rootNode == null) { throw new ArgumentNullException("Input XML Node Can't Be Null"); } foreach (XmlNode node in rootNode.ChildNodes) { if (string.IsNullOrEmpty(node.InnerText)) { continue; } switch (node.LocalName) { case "MessageID": this.messageID = node.InnerText; break; case "SentDateTime": this.sentDateTime = DateTime.Parse(node.InnerText); if (this.sentDateTime.Kind == DateTimeKind.Unspecified) { this.sentDateTime = DateTime.MinValue; throw new ArgumentException("TimeZone Information Must Be Specified"); } this.sentDateTime = this.sentDateTime.ToUniversalTime(); break; case "MessageContentType": this.messageContentType = (MessageType)Enum.Parse(typeof(MessageType), node.InnerText); break; case "MessageDescription": this.messageDescription = node.InnerText; break; case "OriginatingMessageID": this.originatingMessageID = node.InnerText; break; case "PrecedingMessageID": this.precedingMessageID = node.InnerText; break; case "IncidentInformation": if (this.incidentInformation == null) { this.incidentInformation = new List <IncidentInformationType>(); } incidenttemp = new IncidentInformationType(); incidenttemp.ReadXML(node); this.incidentInformation.Add(incidenttemp); break; case "MessageRecall": this.messageRecall = new MessageRecallType(); this.messageRecall.ReadXML(node); break; case "Funding": if (this.funding == null) { this.funding = new List <FundingType>(); } fundtmp = new FundingType(); fundtmp.ReadXML(node); this.funding.Add(fundtmp); break; case "ContactInformation": if (this.contactInformation == null) { this.contactInformation = new List <ContactInformationType>(); } contactinfotmp = new ContactInformationType(); contactinfotmp.ReadXML(node); this.contactInformation.Add(contactinfotmp); break; case "ResourceInformation": if (this.resourceInformation == null) { this.resourceInformation = new List <ResourceInformationType>(); } restmp = new ResourceInformationType(); restmp.ReadXML(node, this.messageContentType); this.resourceInformation.Add(restmp); break; case "#comment": break; default: throw new ArgumentException("Unexpected node name: " + node.Name + " in ResourceMessageType"); } } this.Validate(); }
/// <summary> /// Reads an XML Object From An Existing DOM /// </summary> /// <param name="rootNode">Node Containing the root Object element</param> /// <param name="messageContent">MessageType of this RM Message</param> internal void ReadXML(XmlNode rootNode, MessageType?messageContent) { if (this.keyword == null) { this.keyword = new EDXLSharp.VLList("Keyword"); } this.keyword.ReadXML(rootNode); foreach (XmlNode node in rootNode.ChildNodes) { if (string.IsNullOrEmpty(node.InnerText)) { continue; } switch (node.LocalName) { case "ResourceID": this.resourceID = node.InnerText; break; case "Name": this.name = node.InnerText; break; case "TypeStructure": this.typeStructure = new EDXLSharp.ValueList(); this.typeStructure.ReadXML(node); break; case "TypeInfo": this.typeInfo = XElement.Load(new XmlNodeReader(node)); break; case "Keyword": break; case "Description": this.description = node.InnerText; break; case "Credentials": this.credentials = node.InnerText; break; case "Certifications": this.certifications = node.InnerText; break; case "SpecialRequirements": this.specialRequirements = node.InnerText; break; case "ResponsibleParty": this.responsibleParty = new ContactInformationType(); this.responsibleParty.ReadXML(node); break; case "OwnershipInformation": this.ownershipInformation = new OwnershipInformationType(); this.ownershipInformation.ReadXML(node, messageContent); break; case "ResourceStatus": this.resourceStatus = new ResourceStatusType(); this.resourceStatus.ReadXML(node, messageContent); break; case "#comment": break; default: throw new ArgumentException("Unexpected node name: " + node.Name + " in ResourceType"); } } this.Validate(messageContent); }