コード例 #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(CDvQuantity cDvQuantity)
        {
            this.Validate((CDomainType)cDvQuantity);

            Invariant(cDvQuantity.List == null || !cDvQuantity.List.IsEmpty(), "cDvQuantity.List is not null, implies it must not be empty.");
            Invariant(cDvQuantity.AnyAllowed() ^ (cDvQuantity.List != null || cDvQuantity.Property!=null),
                "cDvQuantity.AnyAllowed() XOR (cDvQuantity.List != null or cDvQuantity.Property != null.)");

            if (cDvQuantity.List != null)
            {
                foreach (CQuantityItem quantityItem in cDvQuantity.List)
                    this.Validate(quantityItem);
            }

            if (cDvQuantity.Property != null)
                this.Validate(cDvQuantity.Property);
        }
コード例 #3
0
ファイル: AmXmlSerializer.cs プロジェクト: nickvane/OpenEHR
        private void WriteXml(CDvQuantity cDomainType)
        {
            string openEhrPrefix = UseOpenEhrPrefix(writer);
            this.WriteXmlBase((CObject)cDomainType);
            if (cDomainType.AssumedValue != null)
            {
                writer.WriteStartElement(openEhrPrefix, "assumed_value", OpenEhrNamespace);
                ((DvQuantity)(cDomainType.AssumedValue)).WriteXml(writer);
                writer.WriteEndElement();
            }

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

            if (cDomainType.List != null)
            {
                foreach (CQuantityItem listItem in cDomainType.List)
                {
                    writer.WriteStartElement(openEhrPrefix, "list", OpenEhrNamespace);
                    this.WriteXml(listItem);
                    writer.WriteEndElement();
                }
            }
        }
コード例 #4
0
ファイル: AmXmlSerializer.cs プロジェクト: nickvane/OpenEHR
        private void ReadXml(CDvQuantity cDomainType)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            this.ReadXmlBase((CObject)cDomainType);

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

            if (reader.LocalName == "property")
            {
                cDomainType.Property = new CodePhrase();
                cDomainType.Property.ReadXml(reader);
            }

            if (reader.LocalName == "list")
            {
                cDomainType.List = new OpenEhr.AssumedTypes.List<CQuantityItem>();
                do
                {
                    CQuantityItem quantityItem = new CQuantityItem();
                    this.ReadXml(quantityItem);
                    cDomainType.List.Add(quantityItem);
                } while (reader.LocalName == "list" && reader.NodeType != XmlNodeType.EndElement);

                Check.Assert(cDomainType.List.Count > 0, "CDvQuantity.List may not be empty.");
            }

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