public DvMultimedia(Text.CodePhrase charset, Text.CodePhrase language, string alternateText, Uri.DvUri uri, byte[] data, Text.CodePhrase mediaType, Text.CodePhrase compressionAlgorithm, byte[] integrityCheck, Text.CodePhrase integrityCheckAlgorithm, int size, DvMultimedia thumbnail) : this() { this.SetBaseData(charset, language); this.alternateText = alternateText; this.uri = uri; this.data = data; this.mediaType = mediaType; this.compressionAlgorithm = compressionAlgorithm; this.integrityCheck = integrityCheck; this.integrityCheckAlgorithm = integrityCheckAlgorithm; this.size = size; this.CheckInvariants(); }
public DvMultimedia(Text.CodePhrase charset, Text.CodePhrase language, string alternateText, Uri.DvUri uri, byte[] data, Text.CodePhrase mediaType, Text.CodePhrase compressionAlgorithm, byte[] integrityCheck, Text.CodePhrase integrityCheckAlgorithm, int size, DvMultimedia thumbnail) : this() { this.SetBaseData(charset, language); this.alternateText = alternateText; this.uri = uri; this.data = data; this.mediaType = mediaType; this.compressionAlgorithm = compressionAlgorithm; this.integrityCheck = integrityCheck; this.integrityCheckAlgorithm = integrityCheckAlgorithm; this.size = size; this.CheckInvariants(); }
protected void SetBaseData(string value, OpenEhr.RM.DataTypes.Uri.DvUri hyperlink, string formatting, List<TermMapping> mappings, CodePhrase language, CodePhrase encoding) { this.value = value; this.hyperlink = hyperlink; this.formatting = formatting; if (mappings != null && mappings.Count > 0) { if (this.mappings == null) this.mappings = new OpenEhr.AssumedTypes.List<TermMapping>(); foreach (TermMapping mapping in mappings) { this.mappings.Add(mapping); } } this.language = language; this.encoding = encoding; }
protected override void ReadXmlBase(System.Xml.XmlReader reader) { //reader.ReadStartElement(); //reader.MoveToContent(); string openEhrNamespace = RmXmlSerializer.OpenEhrNamespace; Check.Assert(reader.LocalName == "value", "reader.LocalName must be 'value'"); //this.value = reader.ReadElementString("value", openEhrNamespace); //this.valueSet = true; SetValue(reader.ReadElementString("value", openEhrNamespace)); reader.MoveToContent(); if (reader.LocalName == "hyperlink") { string linkType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace); if (linkType != null) this.hyperlink = new OpenEhr.RM.DataTypes.Uri.DvEhrUri(); else this.hyperlink = new OpenEhr.RM.DataTypes.Uri.DvUri(); this.hyperlink.ReadXml(reader); } if (reader.LocalName == "formatting") { this.formatting = reader.ReadElementString("formatting", openEhrNamespace); //this.formattingSet = true; } // TODO: TermMapping if (reader.LocalName == "mappings") { this.mappings = new OpenEhr.AssumedTypes.List<TermMapping>(); //new List<TermMapping>(); do { TermMapping mapping = new TermMapping(); mapping.ReadXml(reader); this.mappings.Add(mapping); } while (reader.LocalName == "mapping" && reader.NodeType == System.Xml.XmlNodeType.Element); } // language if (reader.LocalName == "language") { if (this.language == null) this.language = new CodePhrase(); this.language.ReadXml(reader); //this.languageSet = true; } // encoding if (reader.LocalName == "encoding") { if (this.encoding == null) this.encoding = new CodePhrase(); this.encoding.ReadXml(reader); //this.encodingSet = true; } }
protected override void ReadXmlBase(System.Xml.XmlReader reader) { base.ReadXmlBase(reader); if (reader.LocalName == "alternate_text") { this.alternateText = reader.ReadElementString("alternate_text", RmXmlSerializer.OpenEhrNamespace); } reader.MoveToContent(); if (reader.LocalName == "uri") { string uriType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace); if (uriType != null) { Check.Assert(uriType.IndexOf("DV_EHR_URI") > 0, "uriType must be DV_EHR_URI, but it is " + uriType); this.uri = new OpenEhr.RM.DataTypes.Uri.DvEhrUri(); } this.uri = new OpenEhr.RM.DataTypes.Uri.DvUri(); this.uri.ReadXml(reader); } if (reader.LocalName == "data") { reader.MoveToContent(); reader.ReadStartElement(); byte[] buffer = new byte[1024]; System.IO.MemoryStream stream = new System.IO.MemoryStream(); System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); int bytesRead = reader.ReadContentAsBase64(buffer, 0, 1024); while (bytesRead > 0) { writer.Write(buffer, 0, bytesRead); bytesRead = reader.ReadContentAsBase64(buffer, 0, 1024); } writer.Close(); reader.MoveToContent(); reader.ReadEndElement(); this.data = stream.ToArray(); } reader.MoveToContent(); if (reader.LocalName == "media_type") { this.mediaType = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.mediaType.ReadXml(reader); } if (reader.LocalName == "compression_algorithm") { this.compressionAlgorithm = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.compressionAlgorithm.ReadXml(reader); } if (reader.LocalName == "integrity_check") { reader.ReadElementContentAsBase64(this.integrityCheck, 0, this.integrityCheck.Length); } reader.MoveToContent(); if (reader.LocalName == "integrity_check_algorithm") { this.integrityCheckAlgorithm = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.integrityCheckAlgorithm.ReadXml(reader); } Check.Assert(reader.LocalName == "size", "Expected LocalName is 'size', not " + reader.LocalName); this.size = reader.ReadElementContentAsInt("size", RmXmlSerializer.OpenEhrNamespace); reader.MoveToContent(); if (reader.LocalName == "thumbnail") { this.thumbnail = new DvMultimedia(); this.thumbnail.ReadXml(reader); } }
protected override void ReadXmlBase(System.Xml.XmlReader reader) { //reader.ReadStartElement(); //reader.MoveToContent(); string openEhrNamespace = RmXmlSerializer.OpenEhrNamespace; Check.Assert(reader.LocalName == "value", "reader.LocalName must be 'value'"); //this.value = reader.ReadElementString("value", openEhrNamespace); //this.valueSet = true; SetValue(reader.ReadElementString("value", openEhrNamespace)); reader.MoveToContent(); if (reader.LocalName == "hyperlink") { string linkType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace); if (linkType != null) { this.hyperlink = new OpenEhr.RM.DataTypes.Uri.DvEhrUri(); } else { this.hyperlink = new OpenEhr.RM.DataTypes.Uri.DvUri(); } this.hyperlink.ReadXml(reader); } if (reader.LocalName == "formatting") { this.formatting = reader.ReadElementString("formatting", openEhrNamespace); //this.formattingSet = true; } // TODO: TermMapping if (reader.LocalName == "mappings") { this.mappings = new OpenEhr.AssumedTypes.List <TermMapping>(); //new List<TermMapping>(); do { TermMapping mapping = new TermMapping(); mapping.ReadXml(reader); this.mappings.Add(mapping); } while (reader.LocalName == "mapping" && reader.NodeType == System.Xml.XmlNodeType.Element); } // language if (reader.LocalName == "language") { if (this.language == null) { this.language = new CodePhrase(); } this.language.ReadXml(reader); //this.languageSet = true; } // encoding if (reader.LocalName == "encoding") { if (this.encoding == null) { this.encoding = new CodePhrase(); } this.encoding.ReadXml(reader); //this.encodingSet = true; } }
protected override void ReadXmlBase(System.Xml.XmlReader reader) { base.ReadXmlBase(reader); if (reader.LocalName == "alternate_text") this.alternateText = reader.ReadElementString("alternate_text", RmXmlSerializer.OpenEhrNamespace); reader.MoveToContent(); if (reader.LocalName == "uri") { string uriType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace); if (uriType != null) { Check.Assert(uriType.IndexOf("DV_EHR_URI")>0, "uriType must be DV_EHR_URI, but it is "+uriType); this.uri = new OpenEhr.RM.DataTypes.Uri.DvEhrUri(); } this.uri = new OpenEhr.RM.DataTypes.Uri.DvUri(); this.uri.ReadXml(reader); } if (reader.LocalName == "data") { reader.MoveToContent(); reader.ReadStartElement(); byte[] buffer = new byte[1024]; System.IO.MemoryStream stream = new System.IO.MemoryStream(); System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); int bytesRead = reader.ReadContentAsBase64(buffer, 0, 1024); while (bytesRead > 0) { writer.Write(buffer, 0, bytesRead); bytesRead = reader.ReadContentAsBase64(buffer, 0, 1024); } writer.Close(); reader.MoveToContent(); reader.ReadEndElement(); this.data = stream.ToArray(); } reader.MoveToContent(); if (reader.LocalName == "media_type") { this.mediaType = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.mediaType.ReadXml(reader); } if (reader.LocalName == "compression_algorithm") { this.compressionAlgorithm = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.compressionAlgorithm.ReadXml(reader); } if (reader.LocalName == "integrity_check") { reader.ReadElementContentAsBase64(this.integrityCheck, 0, this.integrityCheck.Length); } reader.MoveToContent(); if (reader.LocalName == "integrity_check_algorithm") { this.integrityCheckAlgorithm = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.integrityCheckAlgorithm.ReadXml(reader); } Check.Assert(reader.LocalName=="size", "Expected LocalName is 'size', not " + reader.LocalName); this.size = reader.ReadElementContentAsInt("size", RmXmlSerializer.OpenEhrNamespace); reader.MoveToContent(); if (reader.LocalName == "thumbnail") { this.thumbnail = new DvMultimedia(); this.thumbnail.ReadXml(reader); } }