Beispiel #1
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;
        }
Beispiel #2
0
        protected void Validate(ArchetypeInternalRef archetypeInternalRef)
        {
            this.ValidateBase((CObject)archetypeInternalRef);

            Invariant(!string.IsNullOrEmpty(archetypeInternalRef.TargetPath), string.Format(
                CommonStrings.XMustNotBeNullOrEmpty, "AarchetypeInternalRef.TargetPath"));

            // TODO: Consistency: not any_allowed
            CComplexObject rootDefinition = AmFactory.GetRootDefinition(archetypeInternalRef);
            Invariant(rootDefinition.HasPath(archetypeInternalRef.TargetPath),
                AmValidationStrings.ArchetypeInternalRefTargetPathMissing);
        }
Beispiel #3
0
        private void ReadXml(ArchetypeInternalRef archetypeInternalRef)
        {
            Check.Require(archetypeInternalRef!= null, string.Format(CommonStrings.XMustNotBeNull, "archetypeInternalRef"));

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

            this.ReadXmlBase((CObject)archetypeInternalRef);

            if (reader.LocalName != "target_path")
                throw new InvalidXmlException("target_path", reader.LocalName);
            archetypeInternalRef.TargetPath = reader.ReadElementContentAsString("target_path", OpenEhrNamespace);
            reader.MoveToContent();

            DesignByContract.Check.Assert(!string.IsNullOrEmpty(archetypeInternalRef.TargetPath), "TargetPath must not be null or empty.");
            DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement, "Expected endElement");

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

            this.archetype.ConstraintRepository.Add(archetypeInternalRef.Path, this.archetype.GetCDefinedObjectAtPath(archetypeInternalRef.TargetPath));
        }
Beispiel #4
0
        internal static CComplexObject GetRootDefinition(ArchetypeInternalRef archeytpeInternalRef)
        {
            DesignByContract.Check.Require(archeytpeInternalRef != null, string.Format(CommonStrings.XMustNotBeNull, "archeytpeInternalRef"));
            DesignByContract.Check.Require(archeytpeInternalRef.Parent != null, string.Format(CommonStrings.XMustNotBeNull, "archeytpeInternalRef.Parent"));

            CComplexObject root = null;

            CAttribute parent = archeytpeInternalRef.Parent;
            while (parent != null)
            {
                root = parent.parent;
                parent = root.Parent;
            }

            DesignByContract.Check.Ensure(root != null, "Root definition must not be null.");

            return root;
        }
Beispiel #5
0
        private void WriteXml(ArchetypeInternalRef archetypeInternalRef)
        {
            Check.Require(archetypeInternalRef != null, string.Format(CommonStrings.XMustNotBeNull, "archeytpeInternalRef"));
            Check.Require(!string.IsNullOrEmpty(archetypeInternalRef.TargetPath), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "archetypeInternalRef.TargetPath"));

            this.WriteXmlBase((CObject)archetypeInternalRef);

            writer.WriteElementString(UseOpenEhrPrefix(writer), "target_path", OpenEhrNamespace, archetypeInternalRef.TargetPath);
        }