Esempio n. 1
0
        protected virtual void CloneTree(openehr.openehr.am.archetype.constraint_model.C_COMPLEX_OBJECT adlComplexObject, C_COMPLEX_OBJECT parentComplexObject, int depth)
        {
            CloneConstraintVisitor nodeVisitor = NewInstance();

            openehr.openehr.am.archetype.constraint_model.C_ATTRIBUTE adlAttribute;
            parentComplexObject.attributes = new C_ATTRIBUTE[adlComplexObject.attributes().count()];

            for (int i = 1; i <= adlComplexObject.attributes().count(); i++)
            {
                adlAttribute = adlComplexObject.attributes().i_th(i) as openehr.openehr.am.archetype.constraint_model.C_ATTRIBUTE;
                C_ATTRIBUTE attributeNode = nodeVisitor.CloneAttribute(adlAttribute);
                attributeNode.children = new C_OBJECT[adlAttribute.children().count()];
                parentComplexObject.attributes[i - 1] = attributeNode;

                for (int j = 1; j <= adlAttribute.children().count(); j++)
                {
                    openehr.openehr.am.archetype.constraint_model.C_OBJECT child = adlAttribute.children().i_th(j) as openehr.openehr.am.archetype.constraint_model.C_OBJECT;
                    object childNode = nodeVisitor.Visit(child, depth);
                    attributeNode.children[j - 1] = childNode as C_OBJECT;

                    if (child is openehr.openehr.am.archetype.constraint_model.Impl.C_COMPLEX_OBJECT)
                    {
                        CloneTree(child as openehr.openehr.am.archetype.constraint_model.C_COMPLEX_OBJECT, childNode as C_COMPLEX_OBJECT, ++depth);
                    }
                }
            }
        }
        public static ARCHETYPE BuildFromAdlFile(string adlFilePath, CloneConstraintVisitor visitor)
        {
            [email protected]_INTERFACE adlParser = [email protected]_INTERFACE.make();
            adlParser.open_adl_file(Eiffel.String(adlFilePath));

            // check file opened successfully by checking status
            if (!adlParser.archetype_source_loaded())
                throw new ApplicationException(adlFilePath + "\n" + adlParser.status().to_cil());

            return BuildFromAdlParser(adlParser, visitor);
        }
        public static ARCHETYPE BuildFromAdlFile(string adlFilePath, CloneConstraintVisitor visitor)
        {
            [email protected]_INTERFACE adlParser = [email protected]_INTERFACE.make();
            adlParser.open_adl_file(Eiffel.String(adlFilePath));

            // check file opened successfully by checking status
            if (!adlParser.archetype_source_loaded())
            {
                throw new ApplicationException(adlFilePath + "\n" + adlParser.status().to_cil());
            }

            return(BuildFromAdlParser(adlParser, visitor));
        }
        public static ARCHETYPE Build(openehr.openehr.am.archetype.ARCHETYPE archetype, CloneConstraintVisitor visitor)
        {
            if (archetype == null)
                throw new ArgumentNullException("archetype must not be null");

            if (visitor == null)
                throw new ArgumentNullException("visitor must not be null");

            ARCHETYPE result = visitor.CloneArchetype(archetype);
#if XMLParser
            AmSerializer.ValidateArchetype(result);
#endif
            return result;
        }
        public static ARCHETYPE BuildFromAdlParser([email protected]_INTERFACE adlParser, CloneConstraintVisitor visitor)
        {
            if (adlParser == null)
                throw new ArgumentNullException("adlParser must not be null");

            adlParser.parse_archetype();

            if (!adlParser.parse_succeeded())
                throw new ApplicationException("ADL parsing failed\n" + adlParser.status().to_cil());

            if (!adlParser.archetype_available())
                throw new ApplicationException("ADL archetype unavailable after parsing\n" + adlParser.status().to_cil());

            return Build(adlParser.adl_engine().archetype(), visitor);
        }
        public static ARCHETYPE Build(openehr.openehr.am.archetype.ARCHETYPE archetype, CloneConstraintVisitor visitor)
        {
            if (archetype == null)
            {
                throw new ArgumentNullException("archetype must not be null");
            }

            if (visitor == null)
            {
                throw new ArgumentNullException("visitor must not be null");
            }

            ARCHETYPE result = visitor.CloneArchetype(archetype);

#if XMLParser
            AmSerializer.ValidateArchetype(result);
#endif
            return(result);
        }
        public static ARCHETYPE BuildFromAdlParser([email protected]_INTERFACE adlParser, CloneConstraintVisitor visitor)
        {
            if (adlParser == null)
            {
                throw new ArgumentNullException("adlParser must not be null");
            }

            adlParser.parse_archetype();

            if (!adlParser.parse_succeeded())
            {
                throw new ApplicationException("ADL parsing failed\n" + adlParser.status().to_cil());
            }

            if (!adlParser.archetype_available())
            {
                throw new ApplicationException("ADL archetype unavailable after parsing\n" + adlParser.status().to_cil());
            }

            return(Build(adlParser.adl_engine().archetype(), visitor));
        }
 public static ARCHETYPE BuildFromAdl(string adl, CloneConstraintVisitor visitor)
 {
     [email protected]_INTERFACE adlParser = [email protected]_INTERFACE.make();
     adlParser.adl_engine().set_source(Eiffel.String(adl));
     return(BuildFromAdlParser(adlParser, visitor));
 }
 public static ARCHETYPE BuildFromAdl(string adl, CloneConstraintVisitor visitor)
 {
     [email protected]_INTERFACE adlParser = [email protected]_INTERFACE.make();
     adlParser.adl_engine().set_source(Eiffel.String(adl));
     return BuildFromAdlParser(adlParser, visitor);
 }