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); }
protected void Validate(CDvOrdinal cDvOrdinal) { this.Validate((CDomainType)cDvOrdinal); Invariant(cDvOrdinal.List == null || !cDvOrdinal.List.IsEmpty(), "cDvOrdinal.List is not null, implies it must not be empty."); Invariant(cDvOrdinal.AnyAllowed() ^ cDvOrdinal.List != null, "cDvOrdinal.AnyAllowed() XOR cDvOrdinal.List != null."); if (cDvOrdinal.List != null) { foreach (DvOrdinal dvOrdinal in cDvOrdinal.List) { this.Validate(dvOrdinal); } } }