示例#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));
        }
示例#2
0
 public override bool IsSubsetOf(ArchetypeConstraint other)
 {
     throw new NotImplementedException(
               string.Format(AmValidationStrings.IsSubsetNotImplementedInX, "CComplexObject"));
 }
示例#3
0
        public CObject ConstraintAtPath(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(this);
            }

            if (constraintAtPath.Contains(path))
            {
                return(constraintAtPath[path] as CObject);
            }

            CObject        constraintFound = null;
            ConstraintPath constraintPath  = new ConstraintPath(path);

            if (path.StartsWith("/") && this.Parent != null)
            {
                ArchetypeConstraint rootConstraint = this.ConstraintParent;
                while (rootConstraint.ConstraintParent != null)
                {
                    rootConstraint = rootConstraint.ConstraintParent;
                }

                CComplexObject cComplexObject = rootConstraint as CComplexObject;
                if (cComplexObject == null)
                {
                    throw new ArgumentException(AmValidationStrings.RootConstraintInvalid);
                }

                constraintFound = cComplexObject.ConstraintAtPath(path);
            }
            else
            {
                foreach (CAttribute attribute in this.attributes)
                {
                    if (attribute.RmAttributeName == constraintPath.FirstStepAttributeName)
                    {
                        System.Collections.Generic.IList <CObject> matchedChildren
                            = new System.Collections.Generic.List <CObject>();
                        foreach (CObject cObject in attribute.Children)
                        {
                            if (cObject.NodeId == constraintPath.FirstStepNodeId)
                            {
                                matchedChildren.Add(cObject);
                            }
                            else if (cObject is CArchetypeRoot && cObject.ArchetypeNodeId == constraintPath.FirstStepNodeId)
                            {
                                matchedChildren.Add(cObject);
                            }
                        }
                        if (matchedChildren.Count <= 0)
                        {
                            throw new ArgumentException(string.Format(AmValidationStrings.
                                                                      MissingChildrenWithNodeIdX, constraintPath.FirstStepNodeId));
                        }
                        else if (matchedChildren.Count == 1)
                        {
                            constraintFound = matchedChildren[0];
                        }

                        else if (!constraintPath.HasNameConstraint())
                        {
                            throw new ArgumentException(string.Format(AmValidationStrings.PathYNotUniqueAtX,
                                                                      constraintPath.ToString(), constraintPath.FirstStepNodeId));
                        }
                        else
                        {
                            DvText name = (!string.IsNullOrEmpty(constraintPath.FirstStepNameValue) ?
                                           new DvText(constraintPath.FirstStepNameValue) :
                                           new DvCodedText(constraintPath.FirstStepName));

                            foreach (CObject cObject in matchedChildren)
                            {
                                if (CMultipleAttribute.HasNameAttributeConstraint(cObject, name))
                                {
                                    constraintFound = cObject;
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            if (constraintFound == null)
            {
                throw new ArgumentException(string.Format(AmValidationStrings.NoConstraintForPathX, path));
            }

            CComplexObject complexObject = constraintFound as CComplexObject;

            if (complexObject != null)
            {
                constraintFound = complexObject.ConstraintAtPath(constraintPath.NextSteps);
            }

            this.constraintAtPath.Add(path, constraintFound);

            Check.Ensure(constraintFound != null);

            return(constraintFound);
        }
示例#4
0
 /// <summary>
 /// True if constraints represented by other are narrower than this node. Note: not easily
 /// evaluatable for CONSTRAINT_REF nodes.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public abstract bool IsSubsetOf(ArchetypeConstraint other);
示例#5
0
 public override bool IsSubsetOf(ArchetypeConstraint other)
 {
     throw new Exception("The method or operation is not implemented.");
 }