Microsoft.Xades.CommitmentTypeIndication.GetXml C# (CSharp) Method

GetXml() public method

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

			creationXmlDocument = new XmlDocument();
			retVal = creationXmlDocument.CreateElement("CommitmentTypeIndication", XadesSignedXml.XadesNamespaceUri);

			if (this.commitmentTypeId != null && this.commitmentTypeId.HasChanged())
			{
				retVal.AppendChild(creationXmlDocument.ImportNode(this.commitmentTypeId.GetXml(), true));
			}
			else
			{
				throw new CryptographicException("CommitmentTypeId element missing");
			}

			if (this.allSignedDataObjects)
			{ //Add emty element as required
				bufferXmlElement = creationXmlDocument.CreateElement("AllSignedDataObjects", XadesSignedXml.XadesNamespaceUri);
				retVal.AppendChild(bufferXmlElement);
			}
			else
			{
				if (this.objectReferenceCollection.Count > 0)
				{
					foreach (ObjectReference objectReference in this.objectReferenceCollection)
					{
						if (objectReference.HasChanged())
						{
							retVal.AppendChild(creationXmlDocument.ImportNode(objectReference.GetXml(), true));
						}
					}
				}
			}

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

			return retVal;
		}
		#endregion