Microsoft.Xades.XadesObject.GetXml C# (CSharp) Méthode

GetXml() public méthode

Returns the XML representation of the this object
public GetXml ( ) : XmlElement
Résultat System.Xml.XmlElement
		public XmlElement GetXml()
		{
			XmlDocument creationXmlDocument;
			XmlElement retVal;

			creationXmlDocument = new XmlDocument();
			retVal = creationXmlDocument.CreateElement("ds", "Object", SignedXml.XmlDsigNamespaceUrl);
			if (this.id != null && this.id != "")
			{
				retVal.SetAttribute("Id", this.id);
			}

			if (this.qualifyingProperties != null && this.qualifyingProperties.HasChanged())
			{
				retVal.AppendChild(creationXmlDocument.ImportNode(this.qualifyingProperties.GetXml(), true));
			}

			return retVal;
		}
		#endregion

Usage Example

        /// <summary>
        /// Add a XAdES object to the signature
        /// </summary>
        /// <param name="xadesObject">XAdES object to add to signature</param>
        public void AddXadesObject(XadesObject xadesObject)
        {
            Reference reference;
            DataObject dataObject;
            XmlElement bufferXmlElement;

            if (this.SignatureStandard != KnownSignatureStandard.Xades)
            {
                dataObject = new DataObject();
                dataObject.Id = xadesObject.Id;
                dataObject.Data = xadesObject.GetXml().ChildNodes;
                this.AddObject(dataObject); //Add the XAdES object

                reference = new Reference();
                signedPropertiesIdBuffer = xadesObject.QualifyingProperties.SignedProperties.Id;
                reference.Uri = "#" + signedPropertiesIdBuffer;
                reference.Type = SignedPropertiesType;
                this.AddReference(reference); //Add the XAdES object reference

                this.cachedXadesObjectDocument = new XmlDocument();
                bufferXmlElement = xadesObject.GetXml();

                // Add "ds" namespace prefix to all XmlDsig nodes in the XAdES object
                SetPrefix("ds", bufferXmlElement);

                this.cachedXadesObjectDocument.PreserveWhitespace = true;
                this.cachedXadesObjectDocument.LoadXml(bufferXmlElement.OuterXml); //Cache to XAdES object for later use

                this.signatureStandard = KnownSignatureStandard.Xades;
            }
            else
            {
                throw new CryptographicException("Can't add XAdES object, the signature already contains a XAdES object");
            }
        }