/// <summary> /// Add typed object to the collection /// </summary> /// <param name="objectToAdd">Typed object to be added to collection</param> /// <returns>The object that has been added to collection</returns> public HashDataInfo Add(HashDataInfo objectToAdd) { base.Add(objectToAdd); return(objectToAdd); }
/// <summary> /// Load state from an XML element /// </summary> /// <param name="xmlElement">XML element containing new state</param> public void LoadXml(System.Xml.XmlElement xmlElement) { XmlNamespaceManager xmlNamespaceManager; XmlNodeList xmlNodeList; IEnumerator enumerator; XmlElement iterationXmlElement; HashDataInfo newHashDataInfo; if (xmlElement == null) { throw new ArgumentNullException("xmlElement"); } xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable); xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri); this.hashDataInfoCollection.Clear(); xmlNodeList = xmlElement.SelectNodes("xsd:HashDataInfo", xmlNamespaceManager); enumerator = xmlNodeList.GetEnumerator(); try { while (enumerator.MoveNext()) { iterationXmlElement = enumerator.Current as XmlElement; if (iterationXmlElement != null) { newHashDataInfo = new HashDataInfo(); newHashDataInfo.LoadXml(iterationXmlElement); this.hashDataInfoCollection.Add(newHashDataInfo); } } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } xmlNodeList = xmlElement.SelectNodes("xsd:EncapsulatedTimeStamp", xmlNamespaceManager); if (xmlNodeList.Count != 0) { this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp"); this.encapsulatedTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0)); this.xmlTimeStamp = null; } else { xmlNodeList = xmlElement.SelectNodes("xsd:XMLTimeStamp", xmlNamespaceManager); if (xmlNodeList.Count != 0) { this.xmlTimeStamp = new XMLTimeStamp(); this.xmlTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0)); this.encapsulatedTimeStamp = null; } else { throw new CryptographicException("EncapsulatedTimeStamp or XMLTimeStamp missing"); } } }