/// <summary>
 /// Default constructor
 /// </summary>
 public CommitmentTypeIndication()
 {
     this.commitmentTypeId          = new ObjectIdentifier("CommitmentTypeId");
     this.objectReferenceCollection = new ObjectReferenceCollection();
     this.allSignedDataObjects      = true;
     this.commitmentTypeQualifiers  = new CommitmentTypeQualifiers();
 }
        /// <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;
            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));
            }
        }