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