Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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)));
        }
Exemplo n.º 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)));
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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)
 {
 }
Exemplo n.º 11
0
 public DerivationErrorUnique(DerivationLog derivationLog, DerivationRelation relation)
     : base(derivationLog, new[] { relation }, ErrorMessages.DerivationErrorUnique)
 {
 }
Exemplo n.º 12
0
 public DerivationErrorGeneric(DerivationLog derivationLog, DerivationRelation relation, string message, params object[] messageParam)
     : this(derivationLog, new[] { relation }, message, messageParam)
 {
 }
Exemplo n.º 13
0
 public DerivationErrorRequired(DerivationLog derivationLog, DerivationRelation relation)
     : base(derivationLog, new[] { relation }, ErrorMessages.DerivationErrorRequired)
 {
 }
Exemplo n.º 14
0
 public DerivationErrorConflict(IValidation validation, DerivationRelation relation)
     : base(validation, new[] { relation }, DomainErrors.DerivationErrorConflict)
 {
 }
Exemplo n.º 15
0
 protected DerivationError(DerivationLog derivationLog, DerivationRelation[] relations, string errorMessage)
     : this(derivationLog, relations, errorMessage, new object[] { DerivationRelation.ToString(relations) })
 {
 }
Exemplo n.º 16
0
 public DerivationErrorUnique(IValidation validation, DerivationRelation relation)
     : base(validation, new[] { relation }, DomainErrors.DerivationErrorUnique)
 {
 }
Exemplo n.º 17
0
 public DerivationErrorEquals(DerivationLog derivationLog, DerivationRelation[] derivationRelations)
     : base(derivationLog, derivationRelations, ErrorMessages.DerivationErrorEquals)
 {
 }
Exemplo n.º 18
0
 protected DerivationError(IValidation validation, DerivationRelation[] relations, string errorMessage)
     : this(validation, relations, errorMessage, new object[] { DerivationRelation.ToString(relations) })
 {
 }
Exemplo n.º 19
0
 public DerivationErrorConflict(DerivationLog derivationLog, DerivationRelation relation)
     : base(derivationLog, new[] { relation }, ErrorMessages.DerivationErrorConflict)
 {
 }
Exemplo n.º 20
0
 public DerivationErrorAtLeastOne(DerivationLog derivationLog, DerivationRelation[] derivationRelations)
     : base(derivationLog, derivationRelations, ErrorMessages.DerivationErrorAtLeastOne)
 {
 }
Exemplo n.º 21
0
 public DerivationErrorGeneric(DerivationLog derivationLog, DerivationRelation[] relations, string message, params object[] messageParam)
     : base(derivationLog, relations, message, messageParam)
 {
 }
Exemplo n.º 22
0
 public DerivationErrorRequired(IValidation validation, DerivationRelation relation)
     : base(validation, new[] { relation }, DomainErrors.DerivationErrorRequired)
 {
 }
Exemplo n.º 23
0
 public DerivationErrorAtMostOne(DerivationLog derivationLog, DerivationRelation[] relations)
     : base(derivationLog, relations, ErrorMessages.DerivationErrorAtMostOne)
 {
 }