/// <summary> /// Finish up parsing of elements in mdmolecule. /// </summary> /// <param name="xpath"></param> /// <param name="element"></param> public override void EndElement(CMLStack xpath, XElement element) { if (element.Name.Equals(XName_CML_molecule)) { // add chargeGroup, and then delete them if (currentChargeGroup != null) { if (CurrentMolecule is MDMolecule) { ((MDMolecule)CurrentMolecule).AddChargeGroup(currentChargeGroup); } else { Trace.TraceError("Need to store a charge group, but the current molecule is not a MDMolecule!"); } currentChargeGroup = null; } else // add chargeGroup, and then delete them if (currentResidue != null) { if (CurrentMolecule is MDMolecule) { ((MDMolecule)CurrentMolecule).AddResidue(currentResidue); } else { Trace.TraceError("Need to store a residue group, but the current molecule is not a MDMolecule!"); } currentResidue = null; } else { base.EndElement(xpath, element); } } else if (element.Name == XName_CML_atomArray) { if (xpath.Count == 2 && xpath.EndsWith("molecule", "atomArray")) { StoreAtomData(); NewAtomData(); } else if (xpath.Count > 2 && xpath.EndsWith("cml", "molecule", "atomArray")) { StoreAtomData(); NewAtomData(); } } else if (element.Name == XName_CML_bondArray) { if (xpath.Count == 2 && xpath.EndsWith("molecule", "bondArray")) { StoreBondData(); NewBondData(); } else if (xpath.Count > 2 && xpath.EndsWith("cml", "molecule", "bondArray")) { StoreBondData(); NewBondData(); } } else if (element.Name == XName_CML_scalar) { //Residue number if (string.Equals("md:resNumber", DictRef, StringComparison.Ordinal)) { int myInt = int.Parse(element.Value, NumberFormatInfo.InvariantInfo); currentResidue.SetNumber(myInt); } //ChargeGroup number else if (string.Equals("md:cgNumber", DictRef, StringComparison.Ordinal)) { int myInt = int.Parse(element.Value, NumberFormatInfo.InvariantInfo); currentChargeGroup.SetNumber(myInt); } } else { base.EndElement(xpath, element); } }