Esempio n. 1
0
        private void WriteTConstraint(XmlWriter writer, TConstraint tConstraint)
        {
            Check.Require(tConstraint != null);

            if (tConstraint.Attributes != null && tConstraint.Attributes.Count > 0)
            {
                foreach (TAttribute attribute in tConstraint.Attributes)
                {
                    writer.WriteStartElement(UseOpenEhrPrefix(writer), "attributes", OpenEhrNamespace);
                    WriteTAttribute(writer, attribute);
                    writer.WriteEndElement();
                }
            }
        }
        private void ReadTConstraint(XmlReader reader, TConstraint constraints)
        {
            Check.Require(constraints != null, string.Format(CommonStrings.XMustNotBeNull, "constraints"));
            List <TAttribute> attributeList = new List <TAttribute>();

            reader.ReadStartElement(); // constraints
            reader.MoveToContent();

            while (reader.LocalName == "attributes")
            {
                TAttribute attribute = new TAttribute();
                ReadTAttribute(reader, attribute);
                attributeList.Add(attribute);
                reader.MoveToContent();
                reader.ReadEndElement();
                reader.MoveToContent();
            }

            constraints.Attributes = attributeList;
        }
        public void ReadOperationalTemplate(XmlReader reader, OperationalTemplate template)
        {
            Check.Require(reader != null, string.Format(CommonStrings.XMustNotBeNull, "reader"));
            Check.Require(template != null, string.Format(CommonStrings.XMustNotBeNull, "template"));

            reader.ReadStartElement();  //template
            reader.MoveToContent();

            CodePhrase language = new CodePhrase();

            language.ReadXml(reader);
            template.Language = language;

            if (reader.LocalName == "is_controlled")
            {
                reader.ReadElementContentAsBoolean("is_controlled", RmXmlSerializer.OpenEhrNamespace);
                reader.MoveToContent();
            }

            if (reader.LocalName == "description")
            {
                ResourceDescription description = new ResourceDescription();
                description.ReadXml(reader);
                template.Description = description;
            }

            if (reader.LocalName == "revision_history")
            {
                RevisionHistory revisionHistory = new RevisionHistory();
                revisionHistory.ReadXml(reader);
                template.RevisionHistory = revisionHistory;
            }

            if (reader.LocalName == "uid")
            {
                HierObjectId uid = new HierObjectId();
                uid.ReadXml(reader);
                template.Uid = uid;
            }

            TemplateId templateId = new TemplateId();

            templateId.ReadXml(reader);
            template.TemplateId = templateId;

            template.Concept = reader.ReadElementContentAsString("concept", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            CArchetypeRoot definition = new CArchetypeRoot();

            ReadCArchetypeRoot(reader, definition);
            template.Definition = definition;

            // LMT added 12 May 2010 for TMP-1252
            if (reader.LocalName == "annotations")
            {
                template.Annotations =
                    new List <OpenEhr.RM.Common.Resource.Annotation>();
                OpenEhr.RM.Common.Resource.Annotation currentAnnotation;
                while (reader.LocalName == "annotations")
                {
                    currentAnnotation = ReadAnnotation(reader);
                    template.Annotations.Add(currentAnnotation);
                    reader.MoveToContent();
                }
            }

            if (reader.LocalName == "constraints")
            {
                TConstraint constraints = new TConstraint();
                ReadTConstraint(reader, constraints);
                template.Constraints = constraints;
            }

            if (reader.LocalName == "view")
            {
                TView view = new TView();
                ReadTView(reader, view);
                template.View = view;
            }

            reader.ReadEndElement();    // template
            reader.MoveToContent();
        }
        private void WriteTConstraint(XmlWriter writer, TConstraint tConstraint)
        {
            Check.Require(tConstraint != null);

            if (tConstraint.Attributes != null && tConstraint.Attributes.Count > 0)
            {
                foreach (TAttribute attribute in tConstraint.Attributes)
                {
                    writer.WriteStartElement(UseOpenEhrPrefix(writer), "attributes", OpenEhrNamespace);
                    WriteTAttribute(writer, attribute);
                    writer.WriteEndElement();
                }
            }
        }