protected void Validate(CDefinedObject cDefinedObject) { this.ValidateBase((CObject)cDefinedObject); if (cDefinedObject.HasAssumedValue()) { Invariant(cDefinedObject.ValidValue(cDefinedObject.AssumedValue), AmValidationStrings.AssumedValueInvalid); } }
protected void BuildPath(Path path) { Check.Require(path != null, "path must not be null"); Check.Require(path.Current != null, "current path step must not be null"); string attributeName = path.Current.Attribute; object value = GetAttributeValue(attributeName); if (value == null) { CComplexObject complexObjectConstraint = this.Constraint as CComplexObject; if (complexObjectConstraint == null) { throw new NotImplementedException(); } CAttribute attributeConstraint = complexObjectConstraint.GetAttribute(attributeName); if (attributeConstraint == null) { throw new ApplicationException("constraint for attribute not found"); } CMultipleAttribute multipleAttributeConstraint = attributeConstraint as CMultipleAttribute; if (multipleAttributeConstraint == null) { if (attributeConstraint.Children.Count != 1) { throw new ApplicationException("Single attribute constraint must have exactly one children"); } CObject objectConstraint = attributeConstraint.Children[0]; CDefinedObject definedObjectConstraint = objectConstraint as CDefinedObject; if (definedObjectConstraint == null) { throw new NotImplementedException(); } value = definedObjectConstraint.DefaultValue; SetAttributeValue(attributeName, value); } else { Type itemType = null; value = multipleAttributeConstraint.CreateAggregate(itemType); SetAttributeValue(attributeName, value); } } if (path.NextStep()) { IRmType rmType = value as IRmType; if (rmType == null) { AssumedTypes.IAggregate container = value as AssumedTypes.IAggregate; if (container != null) { container.BuildPath(path); } else { throw new ApplicationException("expected IRmType"); } } else { rmType.BuildPath(path); } } }