Esempio n. 1
0
        private void WriteCAttribute(XmlWriter writer, CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));
            Check.Require(!string.IsNullOrEmpty(cAttribute.RmAttributeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "cAttribute.RmAttributeName"));
            Check.Require(cAttribute.Existence != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute.Existence"));

            string openEhrPrefix = UseOpenEhrPrefix(writer);

            writer.WriteElementString(openEhrPrefix, "rm_attribute_name",
                                      OpenEhrNamespace, cAttribute.RmAttributeName);

            writer.WriteStartElement(openEhrPrefix, "existence", OpenEhrNamespace);
            amSerializer.WriteExistence(writer, cAttribute.Existence);

            writer.WriteEndElement();

            if (cAttribute.Children != null)
            {
                foreach (CObject child in cAttribute.Children)
                {
                    string cChildTypeName = AmType.GetName(child);
                    if (!string.IsNullOrEmpty(openEhrPrefix))
                    {
                        cChildTypeName = string.Format("{0}:{1}", openEhrPrefix, cChildTypeName);
                    }

                    writer.WriteStartElement(openEhrPrefix, "children", OpenEhrNamespace);
                    writer.WriteAttributeString(
                        UseXsiPrefix(writer), "type", RmXmlSerializer.XsiNamespace, cChildTypeName);

                    switch (cChildTypeName)
                    {
                    case "C_ARCHETYPE_ROOT":
                        WriteCArchetypeRoot(writer, (CArchetypeRoot)child);
                        break;

                    case "C_COMPLEX_OBJECT":
                        WriteCComplexObject(writer, (CComplexObject)child);
                        break;

                    default:
                        amSerializer.WriteCObject(writer, child);
                        break;
                    }
                    writer.WriteEndElement();
                }
            }
        }
Esempio n. 2
0
        void WriteCComplexObject(XmlWriter writer, CComplexObject cComplexObject)
        {
            amSerializer.WriteCObject(writer, cComplexObject);

            string openEhrPrefix = UseOpenEhrPrefix(writer);

            if (cComplexObject.Attributes != null && cComplexObject.Attributes.Count > 0)
            {
                foreach (CAttribute attribute in cComplexObject.Attributes)
                {
                    string typeAttribute = AmType.GetName(attribute);

                    if (!string.IsNullOrEmpty(openEhrPrefix))
                    {
                        typeAttribute = string.Format("{0}:{1}",
                                                      openEhrPrefix, typeAttribute);
                    }

                    writer.WriteStartElement(openEhrPrefix, "attributes", OpenEhrNamespace);

                    writer.WriteAttributeString(
                        UseXsiPrefix(writer), "type", XsiNamespace, typeAttribute);

                    if (AmType.GetName(attribute) == "C_MULTIPLE_ATTRIBUTE")
                    {
                        WriteCMulitpleAttribute(writer, attribute);
                    }
                    else
                    {
                        WriteCSingleAttribute(writer, attribute);
                    }

                    writer.WriteEndElement();
                }
            }
        }