Пример #1
0
 public ArchetypeSlot(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences,
   CAttribute parent, AssumedTypes.Set<Assertion.Assertion> includes, 
     AssumedTypes.Set<Assertion.Assertion> excludes): base(rmTypeName, nodeId, occurrences, parent)
 {
     this.Includes = includes;
     this.Excludes = excludes;
 }
Пример #2
0
 public CCodePhrase(TerminologyId terminologyId, List<string> codeList, string rmTypeName, string nodeId, 
     AssumedTypes.Interval<int> occurrences, CAttribute parent, object assumedValue)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
     this.TerminologyId = terminologyId;
     this.CodeList = codeList;
 }
Пример #3
0
 public CDvQuantity(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences,
     CAttribute parent, object assumedValue, List<CQuantityItem> list, CodePhrase property)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
     this.List = list;
     this.Property = property;
 }
Пример #4
0
 protected CObject(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences, 
     CAttribute parent)
 {
     this.RmTypeName = rmTypeName;
     this.Occurrences = occurrences;
     this.NodeId = nodeId;
     this.Parent = parent;
 }
Пример #5
0
 protected CObject(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                   CAttribute parent)
 {
     this.RmTypeName  = rmTypeName;
     this.Occurrences = occurrences;
     this.NodeId      = nodeId;
     this.Parent      = parent;
 }
Пример #6
0
 public ArchetypeSlot(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences,
   CAttribute parent, AssumedTypes.Set<Assertion.Assertion> includes, 
     AssumedTypes.Set<Assertion.Assertion> excludes)
     : base(rmTypeName, nodeId, occurrences, parent)
 {
     this.Includes = includes;
     this.Excludes = excludes;
 }
Пример #7
0
            public MatchingItems(AssumedTypes.IList dataChildren, CObject constraint) : base()
            {
                Check.Require(dataChildren != null, string.Format(CommonStrings.XMustNotBeNull, "dataChildren"));
                Check.Require(constraint != null, string.Format(CommonStrings.XMustNotBeNull, "constraint"));

                Constraint    = constraint;
                NameAttribute = NameAttributeConstraint(constraint);
                Lower         = constraint.Occurrences.Lower;
                Upper         = constraint.Occurrences.UpperUnbounded ? long.MaxValue : constraint.Occurrences.Upper;

                CArchetypeRoot archetypeRoot = constraint as CArchetypeRoot;

                NodeId = archetypeRoot != null ? archetypeRoot.ArchetypeId.Value : constraint.NodeId;

                if (!(constraint is ArchetypeSlot))
                {
                    OpenEhr.AssumedTypes.Impl.ILocatableList locatableItems = dataChildren as OpenEhr.AssumedTypes.Impl.ILocatableList;

                    if (locatableItems != null)
                    {
                        Check.Assert(!string.IsNullOrEmpty(NodeId), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "NodeId"));

                        if (locatableItems.Contains(NodeId))
                        {
                            foreach (OpenEhr.RM.Common.Archetyped.Impl.Locatable locatable in (System.Collections.IEnumerable)locatableItems[NodeId])
                            {
                                if (NameAttribute == null || NameAttribute.ValidValue(locatable.Name))
                                {
                                    Add(locatable);
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (object item in dataChildren)
                        {
                            IRmType rmType = item as IRmType;

                            if (rmType != null && constraint.IsSameRmType(rmType))
                            {
                                Add(item);
                            }
                        }
                    }
                }

                Check.Ensure(Constraint == constraint);
            }
Пример #8
0
        internal static bool ValidateCAttribute(CAttribute cAttribute, ITerminologyService terminologyService)
        {
            AmValidator amValidator = new AmValidator(terminologyService);

            try
            {
                amValidator.Validate(cAttribute);
            }
            catch(Exception ex)
            {
                if (ex.GetType() == typeof(RmInvariantException))
                    return false;
                else
                    throw ex;
            }

            return true;
        }
Пример #9
0
        public static bool HasNameAttributeConstraint(CObject objectConstraint, DvText name, bool requireNameConstraint)
        {
            CAttribute nameConstraint = NameAttributeConstraint(objectConstraint);

            if (nameConstraint == null)
            {
                if (requireNameConstraint)
                {
                    return(false);
                }

                return(true);
            }

            bool nameFound = nameConstraint.ValidValue(name);

            return(nameFound);
        }
Пример #10
0
 public ConstraintRef(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                      CAttribute parent, string reference)
     : base(rmTypeName, nodeId, occurrences, parent)
 {
     this.Reference = Reference;
 }
Пример #11
0
        protected void Validate(CAttribute cAttribute)
        {
            if (cAttribute == null) throw new ArgumentNullException(string.Format(
                CommonStrings.XIsNull, "cAttribute"));

            const string methodName = "Validate";

            try
            {
                System.Reflection.MethodInfo method = this.GetType().GetMethod(methodName,
                    System.Reflection.BindingFlags.ExactBinding | System.Reflection.BindingFlags.NonPublic
                    | System.Reflection.BindingFlags.Instance, Type.DefaultBinder,
                               new Type[] { cAttribute.GetType() },
                               new System.Reflection.ParameterModifier[0]);

                if (method != null)
                {
                    if (method != lastCAttributeMethodRead || cAttribute != lastCAttribute)
                    {
                        lastCAttributeMethodRead = method;
                        lastCAttribute = cAttribute;

                        method.Invoke(this, new Object[] { cAttribute });

                    }
                    else
                    {
                        string message = string.Format(CommonStrings.LoopingMethodTerminated,
                            methodName, cAttribute.GetType().ToString());
                        System.Diagnostics.Debug.WriteLine(message);
                        throw new ApplicationException(message);
                    }
                }
                else
                {
                    string message = string.Format(CommonStrings.MethodXNotImplementedForParamTypeY,
                        methodName, cAttribute.GetType().ToString());
                    System.Diagnostics.Debug.WriteLine(message);
                    throw new ApplicationException(message);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                    if (ex.InnerException is ApplicationException && ex.InnerException.InnerException != null
                            && ex.InnerException.Message == ex.InnerException.InnerException.Message)
                        throw new ApplicationException(ex.InnerException.Message, ex.InnerException.InnerException);
                    else
                        throw new ApplicationException(ex.InnerException.Message, ex.InnerException);
                else
                    throw new ApplicationException(ex.Message, ex);
            }
        }
 private void WriteCSingleAttribute(XmlWriter writer, CAttribute attribute)
 {
     WriteCAttribute(writer, attribute);
 }
        private void WriteCMulitpleAttribute(XmlWriter writer, CAttribute attribute)
        {
            WriteCAttribute(writer, attribute);
            writer.WriteStartElement(
                UseOpenEhrPrefix(writer), "cardinality", RmXmlSerializer.OpenEhrNamespace);

            amSerializer.WriteCardinality(writer, ((CMultipleAttribute)attribute).Cardinality);

            writer.WriteEndElement();
        }
Пример #14
0
        private bool ConstraintReferencesValid(CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));

            if (cAttribute.Children != null)
            {
                foreach (CObject cObj in cAttribute.Children)
                {
                    ConstraintRef constraintRef = cObj as ConstraintRef;
                    if (constraintRef != null)
                    {
                        string reference = constraintRef.Reference;
                        if (this.Ontology.ConstraintCodes == null || !this.Ontology.ConstraintCodes.Has(reference))
                            return false;
                    }

                    else
                    {
                        CComplexObject cComplexObj = cObj as CComplexObject;
                        if (cComplexObj != null && cComplexObj.Attributes != null)
                        {
                            foreach (CAttribute attri in cComplexObj.Attributes)
                                if (!ConstraintReferencesValid(attri))
                                    return false;
                        }
                    }
                }
            }

            return true;
        }
Пример #15
0
 protected CReferenceObject(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences,
   CAttribute parent)
     : base(rmTypeName, nodeId, occurrences, parent)
 {
 }
Пример #16
0
        internal static string LocalTermDefText(string codeString, CAttribute cAttribute)
        {
            Check.Require(!string.IsNullOrEmpty(codeString), "codeString must not be null or empty.");
            Check.Require(cAttribute != null, "cAttribute must not be null");

            CComplexObject parent = cAttribute.parent;
            return LocalTermDefText(codeString, parent);
        }
Пример #17
0
        private bool IsUnorderedChildrenValid(AssumedTypes.IList dataChildren)
        {
            Check.Require(dataChildren != null, string.Format(CommonStrings.XMustNotBeNull, "children"));

            bool result = true;

            foreach (object dataItem in dataChildren)
            {
                System.Collections.Generic.List <CObject> matchedChildren
                    = new System.Collections.Generic.List <CObject>();
                System.Collections.Generic.List <ArchetypeSlot> slots
                    = new System.Collections.Generic.List <ArchetypeSlot>();

                IRmType rmType = dataItem as IRmType;
                Check.Assert(rmType != null, string.Format(AmValidationStrings.XMustImplementY, dataItem.GetType().ToString(), "IRmType"));

                ILocatable locatable = dataItem as ILocatable;

                // get all child constraint objects with this data item's node_id
                foreach (CObject eachChild in Children)
                {
                    if (locatable == null || locatable.ArchetypeNodeId == eachChild.ArchetypeNodeId)
                    {
                        if (eachChild.IsSameRmType(rmType))
                        {
                            matchedChildren.Add(eachChild);
                        }
                    }
                }

                bool matchedWithSlot = false;

                if (matchedChildren.Count == 0)
                {
                    bool validationResult = true;
                    matchedWithSlot = MatchedWithSlot(locatable, out validationResult);

                    if (matchedWithSlot)
                    {
                        result &= validationResult;
                    }
                    else
                    {
                        // child constraint object not found for this data item
                        result = false;
                        string     errorRmTypeName   = rmType.GetRmTypeName();
                        ILocatable locatableDataItem = dataItem as ILocatable;

                        if (locatableDataItem != null)
                        {
                            ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.ItemXWithIdYNotAllowedByAttributeZ, errorRmTypeName, locatableDataItem.ArchetypeNodeId, RmAttributeName));
                        }
                        else
                        {
                            ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.ItemXNotAllowedByAttributeY, errorRmTypeName, RmAttributeName));
                        }
                    }
                }

                CObject unnamedMatchedObject = null;
                bool    validResult          = false;

                // attempt to match data item against child constraint objects with a name attribute constraint
                foreach (CObject matchedObject in matchedChildren)
                {
                    CComplexObject complexObject = matchedObject as CComplexObject;

                    if (complexObject == null)
                    {
                        throw new ApplicationException(AmValidationStrings.MultiAttributeChildNotComplexObj);
                    }

                    CAttribute nameAttribute = NameAttributeConstraint(complexObject);

                    if (nameAttribute != null)
                    {
                        bool nameAttributeFound = false;
                        AcceptValidationError previousErrorDelegate = ValidationContext.AcceptError;

                        try
                        {
                            ValidationContext.AcceptError = null;
                            nameAttributeFound            = nameAttribute.ValidValue(locatable.Name);
                        }
                        finally
                        {
                            ValidationContext.AcceptError = previousErrorDelegate;
                        }

                        if (nameAttributeFound)
                        {
                            validResult = matchedObject.ValidValue(dataItem);

                            if (validResult)
                            {
                                break;
                            }
                            else
                            {
                                result = false;
                            }
                        }
                    }
                    else
                    {
                        // keep child constraint object with no name attribute constraint for later
                        if (unnamedMatchedObject != null)
                        {
                            throw new ApplicationException(AmValidationStrings.ExpectingOnlyOneUnnamedChild);
                        }

                        unnamedMatchedObject = matchedObject;
                    }
                }

                // no matching named object constraint, so attempt to validate against unnamed object constraint
                if (!validResult && !matchedWithSlot)
                {
                    if (unnamedMatchedObject == null)
                    {
                        result = false;
                        ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.NotAllowedByAttributeXConstraint, RmAttributeName));
                    }
                    else if (!unnamedMatchedObject.ValidValue(dataItem))
                    {
                        result = false;
                    }
                }
            }

            return(result);
        }
Пример #18
0
 protected CDefinedObject(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences, 
     CAttribute parent, object assumedValue)
     : base(rmTypeName, nodeId, occurrences, parent)
 {
     this.AssumedValue = assumedValue;
 }
Пример #19
0
        protected void ValidateBase(CAttribute cAttribute)
        {
            this.Validate((ArchetypeConstraint)cAttribute);

            Invariant(!string.IsNullOrEmpty(cAttribute.RmAttributeName), string.Format(
                CommonStrings.XMustNotBeNullOrEmpty, "CAttribute.RmAttributeName"));
            Invariant(cAttribute.Existence != null,  string.Format(
                CommonStrings.XMustNotBeNullOrEmpty, "CAttribute.Existence"));
            this.Validate(cAttribute.Existence);
            Invariant(cAttribute.Existence.Lower >= 0 && cAttribute.Existence.Upper <= 1,
                AmValidationStrings.ExistenceOutOfRange);

            // TODO: Children_validity: any_allowed xor children /= Void

            if (cAttribute.Children != null)
            {
                foreach (CObject cObj in cAttribute.Children)
                    this.Validate(cObj);
            }
        }
Пример #20
0
 public CComplexObject(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences, 
     CAttribute parent, object assumedValue, AssumedTypes.Set<CAttribute> attributes)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
     this.Attributes = attributes;
 }
Пример #21
0
        internal static bool ValidValueTermDef(DvCodedText dvCodedText, CAttribute cAttribute, ITerminologyService terminologyService)
        {
            string value = string.Empty;
            if (dvCodedText.DefiningCode.TerminologyId.Value == OpenEhrTerminologyIdentifiers.TerminologyIdOpenehr)

                value = OpenEhrTermDefTerm(dvCodedText.DefiningCode.CodeString, terminologyService);

            else if (dvCodedText.DefiningCode.TerminologyId.Value == "local")
                value = LocalTermDefText(dvCodedText.DefiningCode.CodeString, cAttribute);

            if (!string.IsNullOrEmpty(value)
                && !string.IsNullOrEmpty(dvCodedText.Value)
                && value != dvCodedText.Value)
            {
                return false;
            }
            if (!string.IsNullOrEmpty(value) && string.IsNullOrEmpty(dvCodedText.Value))
                dvCodedText.Value = value;

            return true;
        }
Пример #22
0
        private bool InternalReferencesValid(CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));

            if (cAttribute.Children != null)
            {
                foreach (CObject cObj in cAttribute.Children)
                {
                    ArchetypeInternalRef archetypeInternalRef = cObj as ArchetypeInternalRef;
                    if (archetypeInternalRef != null)
                    {
                        CObject legitimateNode = GetCObjectAtTargetPath(this.Definition, archetypeInternalRef.TargetPath);
                        if (legitimateNode == null)
                            return false;
                    }

                    else
                    {
                        CComplexObject cComplexObj = cObj as CComplexObject;
                        if (cComplexObj != null && cComplexObj.Attributes != null)
                        {
                            foreach (CAttribute attri in cComplexObj.Attributes)
                                if (!InternalReferencesValid(attri))
                                    return false;
                        }
                    }
                }
            }

            return true;
        }
Пример #23
0
        private void WriteXmlBase(CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));
            Check.Require(!string.IsNullOrEmpty(cAttribute.RmAttributeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "cAttribute.RmAttributeName"));
            Check.Require(cAttribute.Existence != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute.Existence"));

            string openEhrPrefix = UseOpenEhrPrefix(writer);
            writer.WriteElementString(openEhrPrefix, "rm_attribute_name", OpenEhrNamespace, cAttribute.RmAttributeName);

            writer.WriteStartElement(openEhrPrefix, "existence", OpenEhrNamespace);
            this.WriteXml(cAttribute.Existence);
            writer.WriteEndElement();

            if (cAttribute.Children != null)
            {
                foreach (CObject cObj in cAttribute.Children)
                {
                    string cObjType = AmType.GetName(cObj);
                    if (!string.IsNullOrEmpty(openEhrPrefix))
                        cObjType = openEhrPrefix + ":" + cObjType;
                    writer.WriteStartElement(openEhrPrefix, "children", OpenEhrNamespace);
                    writer.WriteAttributeString(UseXsiPrefix(writer), "type", RmXmlSerializer.XsiNamespace, cObjType);

                    this.WriteXml(cObj);
                    writer.WriteEndElement();
                }
            }
        }
Пример #24
0
        private void ReadXmlBase(CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, "cAttribute must not be null.");

            if (reader.LocalName != "rm_attribute_name")
                throw new InvalidXmlException("rm_attribute_name", reader.LocalName);
            cAttribute.RmAttributeName = reader.ReadElementContentAsString("rm_attribute_name", OpenEhrNamespace);

            if (reader.LocalName != "existence")
                throw new InvalidXmlException("existence", reader.LocalName);
            cAttribute.Existence = new Interval<int>();
            this.ReadXml(cAttribute.Existence);

            if (reader.LocalName == "children")
            {
                cAttribute.Children = new OpenEhr.AssumedTypes.List<CObject>();
                do
                {
                    string cObjectType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);
                    DesignByContract.Check.Assert(!string.IsNullOrEmpty(cObjectType), "cObjectType must not be null or empty.");
                    CObject cObj = AmFactory.CObject(cObjectType);

                    cObj.Parent = cAttribute;

                    this.ReadXml(cObj);

                    cAttribute.Children.Add(cObj);

                } while (reader.LocalName == "children" && reader.NodeType != XmlNodeType.EndElement);
            }
        }
Пример #25
0
 public CPrimitiveObject(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                         CAttribute parent, object assumedValue)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
 }
Пример #26
0
        /// <summary>
        /// returns true if all NodeIds valid for an CAttribute object
        /// </summary>
        /// <param name="attri"></param>
        /// <returns></returns>
        private bool NodeIdsValid(CAttribute attri)
        {
            if (attri.Children != null)
            {
                foreach (CObject child in attri.Children)
                {
                    if (!string.IsNullOrEmpty(child.NodeId) && !this.Ontology.HasTermCode(child.NodeId))
                        return false;
                    CComplexObject cComplexObj = child as CComplexObject;
                    if (cComplexObj != null)
                        if (!NodeIdsValid(cComplexObj))
                            return false;
                }
            }

            return true;
        }
Пример #27
0
 public ArchetypeInternalRef(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences,
   CAttribute parent, string targetPath)
     : base(rmTypeName, nodeId, occurrences, parent)
 {
     this.TargetPath = targetPath;
 }
Пример #28
0
 protected CDefinedObject(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                          CAttribute parent, object assumedValue)
     : base(rmTypeName, nodeId, occurrences, parent)
 {
     this.AssumedValue = assumedValue;
 }
Пример #29
0
 protected CDomainType(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                       CAttribute parent, object assumedValue)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
 }
Пример #30
0
 public ArchetypeInternalRef(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                             CAttribute parent, string targetPath)
     : base(rmTypeName, nodeId, occurrences, parent)
 {
     this.TargetPath = targetPath;
 }
Пример #31
0
 public CDvOrdinal(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences,
     CAttribute parent, object assumedValue, Set<DvOrdinal> list)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
     this.List = list;
 }
Пример #32
0
 public CPrimitiveObject(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences,
     CAttribute parent, object assumedValue)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
 }
Пример #33
0
        private bool IsOrderedChildrenValid(AssumedTypes.IList dataChildren)
        {
            Check.Require(dataChildren != null, string.Format(CommonStrings.XMustNotBeNull, "children"));

            int  n      = 0;
            bool result = true;

            foreach (object dataItem in dataChildren)
            {
                int        startingPoint  = n;
                CObject    matchedCObject = null;
                string     dataItemRmType = ((IRmType)dataItem).GetRmTypeName();
                ILocatable locatable      = dataItem as ILocatable;

                while (n < Children.Count)
                {
                    CObject eachChild = Children[n];

                    if (locatable == null || locatable.ArchetypeNodeId == eachChild.ArchetypeNodeId)
                    {
                        if (eachChild.IsSameRmType(dataItem as IRmType))
                        {
                            matchedCObject = eachChild;
                            CComplexObject complexObject = eachChild as CComplexObject;

                            if (complexObject != null)
                            {
                                CAttribute nameAttribute = NameAttributeConstraint(complexObject);

                                if (nameAttribute != null)
                                {
                                    bool nameMatched = false;
                                    AcceptValidationError previousErrorDelegate = ValidationContext.AcceptError;

                                    try
                                    {
                                        ValidationContext.AcceptError = null;
                                        nameMatched = nameAttribute.ValidValue(locatable.Name);
                                    }
                                    finally
                                    {
                                        ValidationContext.AcceptError = previousErrorDelegate;
                                    }

                                    if (nameMatched)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        n++;
                                        continue;
                                    }
                                }
                            }

                            break;
                        }
                    }

                    n++;
                }

                if (matchedCObject == null)
                {
                    n = startingPoint;
                    bool validationResult = true;

                    if (MatchedWithSlot(locatable, out validationResult))
                    {
                        result = validationResult;
                    }
                    else
                    {
                        result = false;
                        ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.YNotAllowedByAttributeXConstraint, RmAttributeName, dataItemRmType));
                    }
                }
                else if (!matchedCObject.ValidValue(dataItem))
                {
                    result = false;
                }
            }

            return(result);
        }
Пример #34
0
 public ConstraintRef(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences,
   CAttribute parent, string reference)
     : base(rmTypeName, nodeId, occurrences, parent)
 {
     this.Reference = Reference;
 }
Пример #35
0
 protected CDomainType(string rmTypeName, string nodeId, AssumedTypes.Interval<int> occurrences,
     CAttribute parent, object assumedValue)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
 }
        private void WriteCAttribute(XmlWriter writer, CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));
            Check.Require(!string.IsNullOrEmpty(cAttribute.RmAttributeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "cAttribute.RmAttributeName"));
            Check.Require(cAttribute.Existence != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute.Existence"));

            string openEhrPrefix = UseOpenEhrPrefix(writer);
            writer.WriteElementString(openEhrPrefix, "rm_attribute_name",
                OpenEhrNamespace, cAttribute.RmAttributeName);

            writer.WriteStartElement(openEhrPrefix, "existence", OpenEhrNamespace);
            amSerializer.WriteExistence(writer, cAttribute.Existence);

            writer.WriteEndElement();

            if (cAttribute.Children != null)
            {
                foreach (CObject child in cAttribute.Children)
                {
                    string cChildTypeName = AmType.GetName(child);
                    if (!string.IsNullOrEmpty(openEhrPrefix))
                        cChildTypeName = string.Format("{0}:{1}", openEhrPrefix, cChildTypeName);

                    writer.WriteStartElement(openEhrPrefix, "children", OpenEhrNamespace);
                    writer.WriteAttributeString(
                        UseXsiPrefix(writer), "type", RmXmlSerializer.XsiNamespace, cChildTypeName);

                    switch (cChildTypeName)
                    {
                        case "C_ARCHETYPE_ROOT" :
                            WriteCArchetypeRoot(writer, (CArchetypeRoot)child);
                            break;

                        case "C_COMPLEX_OBJECT" :
                            WriteCComplexObject(writer, (CComplexObject)child);
                            break;

                        default:
                            amSerializer.WriteCObject(writer, child);
                            break;
                    }
                    writer.WriteEndElement();
                }
            }
        }
Пример #37
0
 public CComplexObject(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                       CAttribute parent, object assumedValue, AssumedTypes.Set <CAttribute> attributes)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
     this.Attributes = attributes;
 }
Пример #38
0
 protected CReferenceObject(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                            CAttribute parent)
     : base(rmTypeName, nodeId, occurrences, parent)
 {
 }