private void ReadTAttribute(XmlReader reader, TAttribute attribute)
        {
            Check.Require(attribute != null);

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

            // Read rm_attribute_name
            Check.Assert(reader.LocalName == "rm_attribute_name");
            attribute.RmAttributeName = reader.ReadElementContentAsString();
            reader.MoveToContent();

            // Read children
            Check.Assert(reader.LocalName == "children", "Expected at least one child in T_ATTRIBUTE");
            attribute.Children = new List <TComplexObject>();
            while (reader.LocalName == "children")
            {
                TComplexObject tComplexObject = new TComplexObject();
                ReadTComplexObject(reader, tComplexObject);
                attribute.Children.Add(tComplexObject);
                reader.ReadEndElement();
                reader.MoveToContent();
            }

            // Read differential path
            Check.Assert(reader.LocalName == "differential_path");
            attribute.DifferentialPath = reader.ReadElementContentAsString();
        }
예제 #2
0
        private void WriteTComplexObject(XmlWriter writer, TComplexObject tComplexObject)
        {
            Check.Require(tComplexObject != null);

            WriteCComplexObject(writer, tComplexObject);
            if (tComplexObject.DefaultValue != null)
            {
                writer.WriteStartElement(UseOpenEhrPrefix(writer), "default_value", OpenEhrNamespace);
                string rmTypeName = ((IRmType)tComplexObject.DefaultValue).GetRmTypeName();
                writer.WriteAttributeString("type", XsiNamespace, rmTypeName);
                tComplexObject.DefaultValue.WriteXml(writer);
                writer.WriteEndElement();
            }
        }
        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;
            }
        }
        private void WriteTComplexObject(XmlWriter writer, TComplexObject tComplexObject)
        {
            Check.Require(tComplexObject != null);

            WriteCComplexObject(writer, tComplexObject);
            if(tComplexObject.DefaultValue != null)
            {
                writer.WriteStartElement(UseOpenEhrPrefix(writer), "default_value", OpenEhrNamespace);
                string rmTypeName = ((IRmType)tComplexObject.DefaultValue).GetRmTypeName();
                writer.WriteAttributeString("type", XsiNamespace, rmTypeName);
                tComplexObject.DefaultValue.WriteXml(writer);
                writer.WriteEndElement();
            }
        }