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

LoadXml() public method

Load state from an XML element
public LoadXml ( System xmlElement ) : void
xmlElement System XML element containing new state
return void
		public void LoadXml(System.Xml.XmlElement xmlElement)
		{
			XmlNamespaceManager xmlNamespaceManager;
			XmlNodeList xmlNodeList;
			IEnumerator enumerator;
			XmlElement iterationXmlElement;
			ObjectReference newObjectReference;
			
			if (xmlElement == null)
			{
				throw new ArgumentNullException("xmlElement");
			}

			xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
			xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

			xmlNodeList = xmlElement.SelectNodes("xsd:CommitmentTypeId", xmlNamespaceManager);
			if (xmlNodeList.Count == 0)
			{
				this.commitmentTypeId = null;
				throw new CryptographicException("CommitmentTypeId missing");
			}
			else
			{
				this.commitmentTypeId = new ObjectIdentifier("CommitmentTypeId");
				this.commitmentTypeId.LoadXml((XmlElement)xmlNodeList.Item(0));
			}

			xmlNodeList = xmlElement.SelectNodes("xsd:ObjectReference", xmlNamespaceManager);
			if (xmlNodeList.Count != 0)
			{
				this.objectReferenceCollection.Clear();
				this.allSignedDataObjects = false;
				enumerator = xmlNodeList.GetEnumerator();
				try 
				{
					while (enumerator.MoveNext()) 
					{
						iterationXmlElement = enumerator.Current as XmlElement;
						if (iterationXmlElement != null)
						{
							newObjectReference = new ObjectReference();
							newObjectReference.LoadXml(iterationXmlElement);
							this.objectReferenceCollection.Add(newObjectReference);
						}
					}
				}
				finally 
				{
					IDisposable disposable = enumerator as IDisposable;
					if (disposable != null)
					{
						disposable.Dispose();
					}
				}

			}
			else
			{
				this.objectReferenceCollection.Clear();
				this.allSignedDataObjects = true;
			}

			xmlNodeList = xmlElement.SelectNodes("xsd:CommitmentTypeQualifiers", xmlNamespaceManager);
			if (xmlNodeList.Count != 0)
			{
				this.commitmentTypeQualifiers = new CommitmentTypeQualifiers();
				this.commitmentTypeQualifiers.LoadXml((XmlElement)xmlNodeList.Item(0));
			}
		}

Usage Example

Example #1
0
		/// <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;
			DataObjectFormat newDataObjectFormat;
			CommitmentTypeIndication newCommitmentTypeIndication;
			TimeStamp newTimeStamp;
			
			if (xmlElement == null)
			{
				throw new ArgumentNullException(nameof(xmlElement));
			}

			xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
			xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

			this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:DataObjectFormat", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newDataObjectFormat = new DataObjectFormat();
						newDataObjectFormat.LoadXml(iterationXmlElement);
						this.dataObjectFormatCollection.Add(newDataObjectFormat);
					}
				}
			}
			finally 
			{
                if (enumerator is IDisposable disposable)
                    disposable.Dispose();
            }

			//this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:CommitmentTypeIndication", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newCommitmentTypeIndication = new CommitmentTypeIndication();
						newCommitmentTypeIndication.LoadXml(iterationXmlElement);
						this.commitmentTypeIndicationCollection.Add(newCommitmentTypeIndication);
					}
				}
			}
			finally 
			{
                if (enumerator is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }

			//this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:AllDataObjectsTimeStamp", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newTimeStamp = new TimeStamp("AllDataObjectsTimeStamp");
						newTimeStamp.LoadXml(iterationXmlElement);
						this.allDataObjectsTimeStampCollection.Add(newTimeStamp);
					}
				}
			}
			finally 
			{
                if (enumerator is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }

			//this.dataObjectFormatCollection.Clear();
			xmlNodeList = xmlElement.SelectNodes("xsd:IndividualDataObjectsTimeStamp", xmlNamespaceManager);
			enumerator = xmlNodeList.GetEnumerator();
			try 
			{
				while (enumerator.MoveNext()) 
				{
					iterationXmlElement = enumerator.Current as XmlElement;
					if (iterationXmlElement != null)
					{
						newTimeStamp = new TimeStamp("IndividualDataObjectsTimeStamp");
						newTimeStamp.LoadXml(iterationXmlElement);
						this.individualDataObjectsTimeStampCollection.Add(newTimeStamp);
					}
				}
			}
			finally 
			{
                if (enumerator is IDisposable disposable)
                    disposable.Dispose();
            }
		}
All Usage Examples Of Microsoft.Xades.CommitmentTypeIndication::LoadXml