Exemple #1
0
        public static DerivationRelation[] Create(IObject association, params RoleType[] roleTypes)
        {
            var derivationRoles = new DerivationRelation[roleTypes.Length];
            for (var i = 0; i < derivationRoles.Length; i++)
            {
                derivationRoles[i] = new DerivationRelation(association, roleTypes[i]);
            }

            return derivationRoles;
        }
Exemple #2
0
        public static DerivationRelation[] Create(IObject role, params AssociationType[] associationTypes)
        {
            var derivationRoles = new DerivationRelation[associationTypes.Length];

            for (var i = 0; i < derivationRoles.Length; i++)
            {
                derivationRoles[i] = new DerivationRelation(role, associationTypes[i]);
            }

            return(derivationRoles);
        }
Exemple #3
0
        public static DerivationRelation[] Create(IObject association, params RoleType[] roleTypes)
        {
            var derivationRoles = new DerivationRelation[roleTypes.Length];

            for (var i = 0; i < derivationRoles.Length; i++)
            {
                derivationRoles[i] = new DerivationRelation(association, roleTypes[i]);
            }

            return(derivationRoles);
        }
Exemple #4
0
        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)));
        }
Exemple #5
0
        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)));
            }
        }
Exemple #6
0
        public static string ToString(DerivationRelation[] relations)
        {
            var stringBuilder = new StringBuilder();
            var first = true;
            foreach (var relation in relations)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    stringBuilder.Append(", ");
                }

                stringBuilder.Append(relation);
            }

            return stringBuilder.ToString();
        }
Exemple #7
0
        protected DerivationError(IValidation validation, DerivationRelation[] relations, string errorMessage, object[] errorMessageParameters)
        {
            this.Validation = validation;
            this.Relations  = relations;

            try
            {
                if (errorMessageParameters != null && errorMessageParameters.Length > 0)
                {
                    this.message = string.Format(errorMessage, errorMessageParameters);
                }
                else
                {
                    this.message = string.Format(errorMessage, new object[] { DerivationRelation.ToString(relations) });
                }
            }
            catch
            {
                this.message = this.GetType() + ": " + DerivationRelation.ToString(this.Relations);
            }
        }
Exemple #8
0
        protected DerivationError(DerivationLog derivationLog, DerivationRelation[] relations, string errorMessage, object[] errorMessageParameters)
        {
            this.derivationLog = derivationLog;
            this.relations = relations;

            try
            {
                if (errorMessageParameters != null && errorMessageParameters.Length > 0)
                {
                    this.message = string.Format(errorMessage, errorMessageParameters);
                }
                else
                {
                    this.message = string.Format(errorMessage, new object[] { DerivationRelation.ToString(relations) });
                }
            }
            catch
            {
                this.message = this.GetType() + ": " + DerivationRelation.ToString(this.relations);
            }
        }
Exemple #9
0
        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)));
            }
        }
 public DerivationErrorGeneric(IValidation validation, DerivationRelation relation, string message, params object[] messageParam)
     : this(validation, new[] { relation }, message, messageParam)
 {
 }
 public DerivationErrorUnique(DerivationLog derivationLog, DerivationRelation relation)
     : base(derivationLog, new[] { relation }, ErrorMessages.DerivationErrorUnique)
 {
 }
 public DerivationErrorGeneric(DerivationLog derivationLog, DerivationRelation relation, string message, params object[] messageParam)
     : this(derivationLog, new[] { relation }, message, messageParam)
 {
 }
 public DerivationErrorRequired(DerivationLog derivationLog, DerivationRelation relation)
     : base(derivationLog, new[] { relation }, ErrorMessages.DerivationErrorRequired)
 {
 }
 public DerivationErrorConflict(IValidation validation, DerivationRelation relation)
     : base(validation, new[] { relation }, DomainErrors.DerivationErrorConflict)
 {
 }
Exemple #15
0
 protected DerivationError(DerivationLog derivationLog, DerivationRelation[] relations, string errorMessage)
     : this(derivationLog, relations, errorMessage, new object[] { DerivationRelation.ToString(relations) })
 {
 }
Exemple #16
0
 public DerivationErrorUnique(IValidation validation, DerivationRelation relation)
     : base(validation, new[] { relation }, DomainErrors.DerivationErrorUnique)
 {
 }
 public DerivationErrorEquals(DerivationLog derivationLog, DerivationRelation[] derivationRelations)
     : base(derivationLog, derivationRelations, ErrorMessages.DerivationErrorEquals)
 {
 }
Exemple #18
0
 protected DerivationError(IValidation validation, DerivationRelation[] relations, string errorMessage)
     : this(validation, relations, errorMessage, new object[] { DerivationRelation.ToString(relations) })
 {
 }
 public DerivationErrorConflict(DerivationLog derivationLog, DerivationRelation relation)
     : base(derivationLog, new[] { relation }, ErrorMessages.DerivationErrorConflict)
 {
 }
 public DerivationErrorAtLeastOne(DerivationLog derivationLog, DerivationRelation[] derivationRelations)
     : base(derivationLog, derivationRelations, ErrorMessages.DerivationErrorAtLeastOne)
 {
 }
 public DerivationErrorGeneric(DerivationLog derivationLog, DerivationRelation[] relations, string message, params object[] messageParam)
     : base(derivationLog, relations, message, messageParam)
 {
 }
 public DerivationErrorRequired(IValidation validation, DerivationRelation relation)
     : base(validation, new[] { relation }, DomainErrors.DerivationErrorRequired)
 {
 }
 public DerivationErrorAtMostOne(DerivationLog derivationLog, DerivationRelation[] relations)
     : base(derivationLog, relations, ErrorMessages.DerivationErrorAtMostOne)
 {
 }