public void AssertAtLeastOne(IObject association, params RoleType[] roleTypes) { foreach (var roleType in roleTypes) { if (association.Strategy.ExistRole(roleType.RelationType)) { return; } } this.AddError(new DerivationErrorAtLeastOne(this, DerivationRelation.Create(association, roleTypes))); }
public void AssertExistsAtMostOne(IObject association, params RoleType[] roleTypes) { var count = 0; foreach (var roleType in roleTypes) { if (association.Strategy.ExistRole(roleType.RelationType)) { ++count; } } if (count > 1) { this.AddError(new DerivationErrorAtMostOne(this, DerivationRelation.Create(association, roleTypes))); } }
public void AssertAreEqual(IObject association, RoleType roleType, RoleType otherRoleType) { var value = association.Strategy.GetRole(roleType.RelationType); var otherValue = association.Strategy.GetRole(otherRoleType.RelationType); bool equal; if (value == null) { equal = otherValue == null; } else { equal = value.Equals(otherValue); } if (!equal) { this.AddError(new DerivationErrorEquals(this, DerivationRelation.Create(association, roleType, otherRoleType))); } }