private void FromXml(String xmlStream) { try { StringReader stringReader = new StringReader(xmlStream); XmlTextReader reader = new XmlTextReader(stringReader); while (reader.EOF == false) { reader.ReadStartElement("ObjectMetaData"); reader.ReadStartElement("EvsSpecificMetaData"); String dicomBinaryObjectDataType = reader.ReadElementString("DicomBinaryObjectDataType"); switch (dicomBinaryObjectDataType) { case "MediaFile": _dicomBinaryObjectDataType = DicomBinaryObjectDataType.MediaFile; break; case "CommandSet": _dicomBinaryObjectDataType = DicomBinaryObjectDataType.CommandSet; break; case "DataSet": _dicomBinaryObjectDataType = DicomBinaryObjectDataType.DataSet; break; default: String message = String.Format("ObjectMetaData.EvsSpecificMetaData.DicomBinaryObjectDataType is \"{0}\" - should be \"MediaFile\", \"CommandSet\" or \"DataSet\"", dicomBinaryObjectDataType); throw new Exception(message); } _sopClassUid = reader.ReadElementString("DicomSopClassUid"); _sopInstanceUid = reader.ReadElementString("DicomSopInstanceUid"); _transferSyntaxUid = reader.ReadElementString("DicomTransferSyntaxUid"); reader.ReadEndElement(); reader.ReadEndElement(); } reader.Close(); } catch (Exception e) { String message = String.Format("Failed to FromXml() DVTK DICOM EVS Object Meta Data XML stream: \"{0}\". Error: \"{1}\"", xmlStream, e.Message); throw new Exception(message, e); } }
private void FromXml(String xmlStream) { try { StringReader stringReader = new StringReader(xmlStream); XmlTextReader reader = new XmlTextReader(stringReader); while (reader.EOF == false) { reader.ReadStartElement("ObjectMetaData"); reader.ReadStartElement("EvsSpecificMetaData"); String dicomBinaryObjectDataType = reader.ReadElementString("DicomBinaryObjectDataType"); switch(dicomBinaryObjectDataType) { case "MediaFile": _dicomBinaryObjectDataType = DicomBinaryObjectDataType.MediaFile; break; case "CommandSet": _dicomBinaryObjectDataType = DicomBinaryObjectDataType.CommandSet; break; case "DataSet": _dicomBinaryObjectDataType = DicomBinaryObjectDataType.DataSet; break; default: String message = String.Format("ObjectMetaData.EvsSpecificMetaData.DicomBinaryObjectDataType is \"{0}\" - should be \"MediaFile\", \"CommandSet\" or \"DataSet\"", dicomBinaryObjectDataType); throw new Exception(message); } _sopClassUid = reader.ReadElementString("DicomSopClassUid"); _sopInstanceUid = reader.ReadElementString("DicomSopInstanceUid"); _transferSyntaxUid = reader.ReadElementString("DicomTransferSyntaxUid"); reader.ReadEndElement(); reader.ReadEndElement(); } reader.Close(); } catch (Exception e) { String message = String.Format("Failed to FromXml() DVTK DICOM EVS Object Meta Data XML stream: \"{0}\". Error: \"{1}\"", xmlStream, e.Message); throw new Exception(message, e); } }