internal void LoadXml(XmlElement value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } XmlNamespaceManager nsmgr = new XmlNamespaceManager(value.OwnerDocument.NameTable); nsmgr.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#"); XmlNodeList xmlNodeList = value.SelectNodes("ds:Transform", nsmgr); if (xmlNodeList.Count == 0) { throw new CryptographicException("Cryptography_Xml_InvalidElement: Transforms"); } this.m_transforms.Clear(); for (int index = 0; index < xmlNodeList.Count; ++index) { XmlElement element = (XmlElement)xmlNodeList.Item(index); Transform fromName = Exml.CreateFromName <Transform>(Exml.GetAttribute(element, "Algorithm", "http://www.w3.org/2000/09/xmldsig#")); if (fromName == null) { throw new CryptographicException("Cryptography_Xml_UnknownTransform"); } fromName.LoadInnerXml(element.ChildNodes); this.m_transforms.Add((object)fromName); } }
/// <summary>Loads a <see cref="T:System.Security.Cryptography.Xml.KeyInfo" /> state from an XML element.</summary> /// <param name="value">The XML element from which to load the <see cref="T:System.Security.Cryptography.Xml.KeyInfo" /> state. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="value" /> parameter is <see langword="null" />. </exception> public void LoadXml(XmlElement value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } XmlElement element1 = value; this.m_id = Exml.GetAttribute(element1, "Id", "http://www.w3.org/2000/09/xmldsig#"); if (!Exml.VerifyAttributes(element1, "Id")) { throw new CryptographicException("Invalid XML element: KeyInfo"); } for (XmlNode xmlNode = element1.FirstChild; xmlNode != null; xmlNode = xmlNode.NextSibling) { XmlElement element2 = xmlNode as XmlElement; if (element2 != null) { string key = element2.NamespaceURI + " " + element2.LocalName; if (key == "http://www.w3.org/2000/09/xmldsig# KeyValue") { if (!Exml.VerifyAttributes(element2, (string[])null)) { throw new CryptographicException("Invalid XML element: KeyInfo/KeyValue"); } foreach (XmlNode childNode in element2.ChildNodes) { XmlElement xmlElement = childNode as XmlElement; if (xmlElement != null) { key = key + "/" + xmlElement.LocalName; break; } } } KeyInfoClause clause = Exml.CreateFromName <KeyInfoClause>(key) ?? (KeyInfoClause) new KeyInfoNode(); clause.LoadXml(element2); this.AddClause(clause); } } }