Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }