예제 #1
0
        protected void Validate(ConstraintRef constraintRef)
        {
            this.ValidateBase((CObject)constraintRef);

            Invariant(constraintRef.Reference != null, string.Format(
                          CommonStrings.XMustNotBeNull, "ConstraintRef.Reference"));

            // TODO: Consistency: not any_allowed
        }
예제 #2
0
        private static ConstraintRef Map(this CONSTRAINT_REF model)
        {
            var constraintRef = new ConstraintRef
            {
                NodeId                 = model.node_id,
                Occurences             = model.occurrences.Map(),
                Reference              = model.reference,
                ReferenceModelTypeName = model.rm_type_name
            };

            return(constraintRef);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
0
 public void IsValidThrowsException()
 {
     var instance = new ConstraintRef();
     var result   = instance.IsValid();
 }
예제 #6
0
 public void IsSubsetOfThrowsException()
 {
     var instance = new ConstraintRef();
     var result   = instance.IsSubsetOf(null);
 }