Exemplo n.º 1
0
        protected override void ReadXmlBase(System.Xml.XmlReader reader)
        {
            base.ReadXmlBase(reader);

            if (reader.LocalName == "attested_view")
            {
                this.attestedView = new OpenEhr.RM.DataTypes.Encapsulated.DvMultimedia();
                this.attestedView.ReadXml(reader);
            }

            if (reader.LocalName == "proof")
            {
                this.proof = reader.ReadElementString("proof", RmXmlSerializer.OpenEhrNamespace);
                reader.MoveToContent();
            }

            if (reader.LocalName == "items")
            {
                this.items = new OpenEhr.AssumedTypes.List <OpenEhr.RM.DataTypes.Uri.DvEhrUri>();
                do
                {
                    DataTypes.Uri.DvEhrUri uri = new OpenEhr.RM.DataTypes.Uri.DvEhrUri();
                    uri.ReadXml(reader);

                    this.items.Add(uri);
                } while (reader.LocalName == "items");
            }

            if (reader.LocalName != "reason")
            {
                throw new ValidationException("Excepted element name is reason, but it is: " + reader.LocalName);
            }
            string reasonType = RmXmlSerializer.ReadXsiType(reader);

            if (!string.IsNullOrEmpty(reasonType))
            {
                this.reason = RmFactory.DataValue(reasonType) as DataTypes.Text.DvText;
            }
            else
            {
                this.reason = new OpenEhr.RM.DataTypes.Text.DvText();
            }
            this.reason.ReadXml(reader);

            if (reader.LocalName != "is_pending")
            {
                throw new ValidationException("Excepted element name is is_pending, but it is: " + reader.LocalName);
            }
            this.isPending = reader.ReadElementContentAsBoolean("is_pending", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();
        }
Exemplo n.º 2
0
        protected override void ReadXmlBase(System.Xml.XmlReader reader)
        {
            if (reader.LocalName == "lower")
            {
                string type = RmXmlSerializer.ReadXsiType(reader);
                this.lower = RmFactory.DataValue(type) as T;
                Check.Assert(this.lower != null, "lower must not be null");

                this.lower.ReadXml(reader);

                reader.MoveToContent();
            }

            if (reader.LocalName == "upper")
            {
                string type = RmXmlSerializer.ReadXsiType(reader);
                this.upper = RmFactory.DataValue(type) as T;
                Check.Assert(this.upper != null, "lower must not be null");

                this.upper.ReadXml(reader);

                reader.MoveToContent();
            }

            if (reader.LocalName == "lower_included")
            {
                this.lowerIncluded    = reader.ReadElementContentAsBoolean();
                this.lowerIncludedSet = true;
                reader.MoveToContent();
            }

            if (reader.LocalName == "upper_included")
            {
                this.upperIncluded    = reader.ReadElementContentAsBoolean();
                this.upperIncludedSet = true;
                reader.MoveToContent();
            }

            Check.Assert(reader.LocalName == "lower_unbounded", "localName must be 'lower_unbounded'");
            this.lowerUnbounded    = reader.ReadElementContentAsBoolean();
            this.lowerUnboundedSet = true;
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "upper_unbounded", "localName must be 'upper_unbounded'");
            this.upperUnbounded    = reader.ReadElementContentAsBoolean();
            this.upperUnboundedSet = true;
            reader.MoveToContent();

            CheckInvariants();
        }
        private void ReadTComplexObject(XmlReader reader, TComplexObject tComplexObject)
        {
            Check.Require(tComplexObject != null, string.Format(CommonStrings.XMustNotBeNull, "tComplexObject"));

            ReadCComplexObject(reader, tComplexObject);

            // Read default_value
            if (reader.LocalName == "default_value")
            {
                string rmType = ReadXsiType(reader);
                Check.Assert(!string.IsNullOrEmpty(rmType), "xsi:type should not be null or empty");
                DataValue defaultValue = RmFactory.DataValue(rmType);
                defaultValue.ReadXml(reader);
                tComplexObject.DefaultValue = defaultValue;
            }
        }
Exemplo n.º 4
0
        internal void ReadXml(XmlReader reader)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "function",
                         "Expected LocalName is 'function' not " + reader.LocalName);
            string functionType = RmXmlSerializer.ReadXsiType(reader);

            if (!string.IsNullOrEmpty(functionType))
            {
                this.function = RmFactory.DataValue(functionType) as DataTypes.Text.DvText;
            }
            else
            {
                this.function = new OpenEhr.RM.DataTypes.Text.DvText();
            }
            this.function.ReadXml(reader);
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "performer",
                         "Expected LocalName is 'performer' not " + reader.LocalName);
            string performerType = RmXmlSerializer.ReadXsiType(reader);

            this.performer = RmFactory.PartyProxy(performerType);

            this.performer.ReadXml(reader);

            if (reader.LocalName == "time")
            {
                this.time = new OpenEhr.RM.DataTypes.Quantity.DvInterval <OpenEhr.RM.DataTypes.Quantity.DateTime.DvDateTime>();
                this.time.ReadXml(reader);
            }

            Check.Assert(reader.LocalName == "mode", "Expected LocalName is 'mode' not " + reader.LocalName);
            this.mode = new OpenEhr.RM.DataTypes.Text.DvCodedText();
            this.mode.ReadXml(reader);

            DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement,
                                          "Expected endElement of PartyIdentified.");
            reader.ReadEndElement();
            reader.MoveToContent();
        }
Exemplo n.º 5
0
        public static DataValue ReadDataValue(System.Xml.XmlReader reader)
        {
            DataValue dataValue = null;

            string valueType = RmXmlSerializer.ReadXsiType(reader);

            Check.Assert(!string.IsNullOrEmpty(valueType), "value type must not be null or empty.");

            switch (valueType)
            {
            case "DV_INTERVAL":
                reader.ReadStartElement();
                reader.MoveToContent();

                if (reader.LocalName != "lower" && reader.LocalName != "upper")
                {
                    throw new ApplicationException("interval must have lower or upper element");
                }

                string intervalType = RmXmlSerializer.ReadXsiType(reader);

                dataValue = CreateInterval(intervalType);
                dataValue.ReadXmlBase(reader);

                DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement,
                                              "Expected endElement after calling ReadXml");
                reader.ReadEndElement();
                reader.MoveToContent();

                break;

            default:
                dataValue = RmFactory.DataValue(valueType);

                dataValue.ReadXml(reader);
                break;
            }

            DesignByContract.Check.Ensure(dataValue != null, "dataValue must not be null.");
            return(dataValue);
        }
Exemplo n.º 6
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "meaning",
                         "Expected LocalName is meaning rather than " + reader.LocalName);
            if (this.meaning == null)
            {
                string meaningType = RmXmlSerializer.ReadXsiType(reader);
                if (meaningType == null)
                {
                    this.meaning = new DvText();
                }
                else
                {
                    this.meaning = RmFactory.DataValue(meaningType) as DvText;
                }
            }
            this.meaning.ReadXml(reader);

            DesignByContract.Check.Assert(reader.LocalName == "range",
                                          "Expected LocalName is range rather than " + reader.LocalName);
            if (this.range == null)
            {
                this.range = new DvInterval <T>();
            }
            this.range.ReadXml(reader);

            if (!reader.IsStartElement())
            {
                reader.ReadEndElement();
            }
            reader.MoveToContent();

            this.CheckInvariants();
        }