コード例 #1
0
ファイル: AmFactory.cs プロジェクト: nickvane/OpenEHR
        internal static CObject CObject(string typeName)
        {
            DesignByContract.Check.Require(!string.IsNullOrEmpty(typeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "typeName"));

            CObject cObject = null;
            switch (typeName)
            {
                case "C_COMPLEX_OBJECT":
                    cObject = new CComplexObject();
                    break;
                case "C_PRIMITIVE_OBJECT":
                    cObject = new CPrimitiveObject();
                    break;
                case "ARCHETYPE_INTERNAL_REF":
                    cObject = new ArchetypeInternalRef();
                    break;
                case "CONSTRAINT_REF":
                    cObject = new ConstraintRef();
                    break;
                case "ARCHETYPE_SLOT":
                    cObject = new ArchetypeSlot();
                    break;
                case "C_CODE_PHRASE":
                    cObject = new CCodePhrase();
                    break;
                case "C_DV_STATE":
                    cObject = new CDvState();
                    break;
                case "C_DV_ORDINAL":
                    cObject = new CDvOrdinal();
                    break;
                case "C_DV_QUANTITY":
                    cObject = new CDvQuantity();
                    break;
                default:
                    throw new NotSupportedException("type not supported: " + typeName);
            }

            DesignByContract.Check.Ensure(cObject != null, "cObject must not be null.");

            return cObject;
        }
コード例 #2
0
ファイル: AmValidator.cs プロジェクト: nickvane/OpenEHR
        protected void Validate(CCodePhrase cCodePhrase)
        {
            this.Validate((CDomainType)cCodePhrase);

            Invariant(cCodePhrase.CodeList == null || (!cCodePhrase.CodeList.IsEmpty() && cCodePhrase.TerminologyId != null),
                "cCodePhrase.CodeList is not null, implies it must not be empty and terminologyId must not be null.");

            Invariant(cCodePhrase.AnyAllowed() ^ cCodePhrase.TerminologyId != null,
                "cCodePhrase.AnyAllowed xor cCodePhrase.TerminologyId must not be null.");
        }
コード例 #3
0
ファイル: AmXmlSerializer.cs プロジェクト: nickvane/OpenEHR
        private void WriteXml(CCodePhrase cDomainType)
        {
            string openEhrPrefix = UseOpenEhrPrefix(writer);
            this.WriteXmlBase((CObject)cDomainType);
            if (cDomainType.AssumedValue != null)
            {
                writer.WriteStartElement(openEhrPrefix, "assumed_value", OpenEhrNamespace);
                ((CodePhrase)(cDomainType.AssumedValue)).WriteXml(writer);
                writer.WriteEndElement();
            }

            if (cDomainType.TerminologyId != null)
            {
                writer.WriteStartElement(openEhrPrefix, "terminology_id", OpenEhrNamespace);
                cDomainType.TerminologyId.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (cDomainType.CodeList != null)
            {
                foreach (string listItem in cDomainType.CodeList)
                {
                    writer.WriteElementString(openEhrPrefix, "code_list", OpenEhrNamespace, listItem);
                }
            }
        }
コード例 #4
0
ファイル: AmXmlSerializer.cs プロジェクト: nickvane/OpenEHR
        private void ReadXml(CCodePhrase cDomainType)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            this.ReadXmlBase((CObject)cDomainType);

            if (reader.LocalName == "assumed_value")
            {
                CodePhrase assumedValue = new CodePhrase();
                assumedValue.ReadXml(reader);
                cDomainType.AssumedValue = assumedValue;
            }

            if (reader.LocalName == "terminology_id")
            {
                cDomainType.TerminologyId = new TerminologyId();
                cDomainType.TerminologyId.ReadXml(reader);
            }

            if (reader.LocalName == "code_list")
            {
                OpenEhr.AssumedTypes.List<string> codeList = new OpenEhr.AssumedTypes.List<string>();
                do
                {
                    string codeString = reader.ReadElementContentAsString("code_list", OpenEhrNamespace);
                    reader.MoveToContent();
                    codeList.Add(codeString);
                } while (reader.LocalName == "code_list");

                Check.Assert(!codeList.IsEmpty(), "codeList must not be empty.");

                cDomainType.CodeList = codeList;
            }

            reader.ReadEndElement();
            reader.MoveToContent();
        }