Example #1
0
        public override bool IsSubsetOf(ArchetypeConstraint other)
        {
            Check.Require(other != null, string.Format(CommonStrings.XMustNotBeNull, "other"));

            CPrimitiveObject otherPrimitive = other as CPrimitiveObject;

            if (otherPrimitive == null)
            {
                return(false);
            }

            if (this.Item.GetType() != otherPrimitive.Item.GetType())
            {
                return(false);
            }

            return(this.Item.IsSubsetOf(otherPrimitive.Item));
        }
Example #2
0
        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;
        }
Example #3
0
        protected void Validate(CPrimitiveObject cPrimitiveObject)
        {
            this.Validate((CDefinedObject)cPrimitiveObject);

            Invariant(cPrimitiveObject.AnyAllowed() ^ cPrimitiveObject.Item != null,
                AmValidationStrings.CPrimitiveObjectAllowAnyXor);

            if (cPrimitiveObject.Item != null)
                this.Validate(cPrimitiveObject.Item);
        }
Example #4
0
        private void ReadXml(CPrimitiveObject cPrimitiveObj)
        {
            Check.Require(cPrimitiveObj != null, string.Format(CommonStrings.XMustNotBeNull, "cPrimitiveObj"));

            reader.ReadStartElement();
            reader.MoveToContent();

            this.ReadXmlBase((CObject)cPrimitiveObj);
            if (reader.LocalName != "item")
                throw new InvalidXmlException("item", reader.LocalName);
            string itemType = reader.GetAttribute("type", XsiNamespace);
            Check.Assert(!string.IsNullOrEmpty(itemType), "itemType must not be null or empty.");
            cPrimitiveObj.Item = AmFactory.CPrimitive(itemType);

            this.ReadXml(cPrimitiveObj.Item);

            DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement, "Expected endElement");
            reader.ReadEndElement();

            reader.MoveToContent();

            if (this.archetype != null)
                this.archetype.ConstraintRepository.Add(cPrimitiveObj.Path, cPrimitiveObj);
        }
Example #5
0
        private void WriteXml(CPrimitiveObject cPrimitiveObj)
        {
            Check.Require(cPrimitiveObj != null, string.Format(CommonStrings.XMustNotBeNull, "cPrimitiveObj"));

            this.WriteXmlBase((CObject)cPrimitiveObj);

            writer.WriteStartElement(UseOpenEhrPrefix(writer), "item", OpenEhrNamespace);
            string itemType = AmType.GetName(cPrimitiveObj.Item);
            writer.WriteAttributeString(UseXsiPrefix(writer), "type", XsiNamespace, itemType);
            if (cPrimitiveObj.Item != null)
                this.WriteXml(cPrimitiveObj.Item);
            writer.WriteEndElement();
        }