/// <summary> /// Validates this instance. /// </summary> /// <param name="validationLog">The validation.</param> protected internal override void Validate(ValidationLog validationLog) { base.Validate(validationLog); if (this.Subtype != null && this.Supertype != null) { if (this.MetaPopulation.Inheritances.Count(inheritance => this.Subtype.Equals(inheritance.Subtype) && this.Supertype.Equals(inheritance.Supertype)) != 1) { var message = "name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "Inheritance.Supertype"); } IObjectType tempQualifier = this.Supertype; if (tempQualifier is IClass) { var message = this.ValidationName + " can not have a concrete superclass"; validationLog.AddError(message, this, ValidationKind.Hierarchy, "Inheritance.Supertype"); } } else { if (this.Supertype == null) { var message = this.ValidationName + " has a missing Supertype"; validationLog.AddError(message, this, ValidationKind.Unique, "Inheritance.Supertype"); } else { var message = this.ValidationName + " has a missing Subtype"; validationLog.AddError(message, this, ValidationKind.Unique, "Inheritance.Supertype"); } } }
/// <summary> /// Validates the domain. /// </summary> /// <param name="validationLog">The validation.</param> protected internal override void Validate(ValidationLog validationLog) { base.Validate(validationLog); if (string.IsNullOrEmpty(this.Name)) { validationLog.AddError("domain has no name", this, ValidationKind.Required, "Domain.Name"); } else { if (!char.IsLetter(this.Name[0])) { var message = this.ValidationName + " should start with an alfabetical character"; validationLog.AddError(message, this, ValidationKind.Format, "Domain.Name"); } for (var i = 1; i < this.Name.Length; i++) { if (!char.IsLetter(this.Name[i]) && !char.IsDigit(this.Name[i])) { var message = this.ValidationName + " should only contain alfanumerical characters)"; validationLog.AddError(message, this, ValidationKind.Format, "Domain.Name"); break; } } } if (this.Id == Guid.Empty) { validationLog.AddError(this.ValidationName + " has no id", this, ValidationKind.Required, "IMetaObject.Id"); } }
/// <summary> /// Validates this. instance. /// </summary> /// <param name="validationLog">The validation.</param> protected internal override void Validate(ValidationLog validationLog) { base.Validate(validationLog); if (this.AssociationType != null && this.RoleType != null) { if (validationLog.ExistRelationName(this.Name)) { var message = "name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "RelationType.Name"); } else { validationLog.AddRelationTypeName(this.Name); } if (validationLog.ExistRelationName(this.ReverseName)) { var message = "reversed name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "RelationType.Name"); } else { validationLog.AddRelationTypeName(this.ReverseName); } if (validationLog.ExistObjectTypeName(this.Name)) { var message = "name of " + this.ValidationName + " is in conflict with object type " + this.Name; validationLog.AddError(message, this, ValidationKind.Unique, "RelationType.Name"); } if (validationLog.ExistObjectTypeName(this.ReverseName)) { var message = "reversed name of " + this.ValidationName + " is in conflict with object type " + this.Name; validationLog.AddError(message, this, ValidationKind.Unique, "RelationType.Name"); } } else { if (this.AssociationType == null) { var message = this.ValidationName + " has no association type"; validationLog.AddError(message, this, ValidationKind.Required, "RelationType.AssociationType"); } else { var message = this.ValidationName + " has no role type"; validationLog.AddError(message, this, ValidationKind.Required, "RelationType.RoleType"); } } this.AssociationType?.Validate(validationLog); this.RoleType?.Validate(validationLog); }
/// <summary> /// Validates the instance. /// </summary> /// <param name="validationLog">The validation.</param> protected internal override void Validate(ValidationLog validationLog) { base.Validate(validationLog); if (string.IsNullOrEmpty(this.name)) { var message = this.ValidationName + " has no name"; validationLog.AddError(message, this, ValidationKind.Required, "MethodType.Name"); } }
/// <summary> /// Validates this object. /// </summary> /// <param name="validationLog">The validation information.</param> protected internal override void Validate(ValidationLog validationLog) { if (this.ObjectType == null) { var message = this.ValidationName + " has no object type"; validationLog.AddError(message, this, ValidationKind.Required, "AssociationType.IObjectType"); } if (this.RelationType == null) { var message = this.ValidationName + " has no relation type"; validationLog.AddError(message, this, ValidationKind.Required, "AssociationType.RelationType"); } }
/// <summary> /// Validates the instance. /// </summary> /// <param name="validationLog">The validation.</param> protected internal void Validate(ValidationLog validationLog) { if (this.ObjectType == null) { var message = this.ValidationName + " has no IObjectType"; validationLog.AddError(message, this, ValidationKind.Required, "RoleType.IObjectType"); } if (!string.IsNullOrEmpty(this.AssignedSingularName) && this.AssignedSingularName.Length < 2) { var message = this.ValidationName + " should have an assigned singular name with at least 2 characters"; validationLog.AddError(message, this, ValidationKind.MinimumLength, "RoleType.AssignedSingularName"); } if (!string.IsNullOrEmpty(this.AssignedPluralName) && this.AssignedPluralName.Length < 2) { var message = this.ValidationName + " should have an assigned plural role name with at least 2 characters"; validationLog.AddError(message, this, ValidationKind.MinimumLength, "RoleType.AssignedPluralName"); } }
/// <summary> /// Validate this object. /// </summary> /// <param name="validationLog"> /// The validation log. /// </param> protected internal virtual void Validate(ValidationLog validationLog) { if (this.Id == Guid.Empty) { var message = "id on " + this.ValidationName + " is required"; validationLog.AddError(message, this, ValidationKind.Unique, "IMetaObject.Id"); } else { if (validationLog.ExistId(this.Id)) { var message = "id " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "IMetaObject.Id"); } else { validationLog.AddId(this.Id); } } }
/// <summary> /// Validates this. instance. /// </summary> /// <param name="validationLog">The validation.</param> protected internal override void Validate(ValidationLog validationLog) { base.Validate(validationLog); if (this.AssociationType != null && this.RoleType != null) { if (validationLog.ExistRelationName(this.Name)) { var message = "name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "RelationType.Name"); } else { validationLog.AddRelationTypeName(this.Name); } if (validationLog.ExistRelationName(this.ReverseName)) { var message = "reversed name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "RelationType.Name"); } else { validationLog.AddRelationTypeName(this.ReverseName); } if (validationLog.ExistObjectTypeName(this.Name)) { var message = "name of " + this.ValidationName + " is in conflict with object type " + this.Name; validationLog.AddError(message, this, ValidationKind.Unique, "RelationType.Name"); } if (validationLog.ExistObjectTypeName(this.ReverseName)) { var message = "reversed name of " + this.ValidationName + " is in conflict with object type " + this.Name; validationLog.AddError(message, this, ValidationKind.Unique, "RelationType.Name"); } } else { if (this.AssociationType == null) { var message = this.ValidationName + " has no association type"; validationLog.AddError(message, this, ValidationKind.Required, "RelationType.AssociationType"); } else { var message = this.ValidationName + " has no role type"; validationLog.AddError(message, this, ValidationKind.Required, "RelationType.RoleType"); } } if (this.AssociationType != null) { this.AssociationType.Validate(validationLog); } if (this.RoleType != null) { this.RoleType.Validate(validationLog); } }
/// <summary> /// Validates this instance. /// </summary> /// <returns>The Validate.</returns> public ValidationLog Validate() { var log = new ValidationLog(); foreach (var domain in this.Domains) { domain.Validate(log); } foreach (var unitType in this.Units) { unitType.Validate(log); } foreach (var @interface in this.Interfaces) { @interface.Validate(log); } foreach (var @class in this.Classes) { @class.Validate(log); } foreach (var inheritance in this.Inheritances) { inheritance.Validate(log); } foreach (var relationType in this.RelationTypes) { relationType.Validate(log); } foreach (var methodType in this.MethodTypes) { methodType.Validate(log); } var inheritancesBySubtype = new Dictionary <Composite, List <Inheritance> >(); foreach (var inheritance in this.Inheritances) { var subtype = inheritance.Subtype; if (subtype != null) { List <Inheritance> inheritanceList; if (!inheritancesBySubtype.TryGetValue(subtype, out inheritanceList)) { inheritanceList = new List <Inheritance>(); inheritancesBySubtype[subtype] = inheritanceList; } inheritanceList.Add(inheritance); } } var supertypes = new HashSet <Interface>(); foreach (var subtype in inheritancesBySubtype.Keys) { supertypes.Clear(); if (this.HasCycle(subtype, supertypes, inheritancesBySubtype)) { var message = subtype.ValidationName + " has a cycle in its inheritance hierarchy"; log.AddError(message, subtype, ValidationKind.Cyclic, "IComposite.Supertypes"); } } return(log); }
/// <summary> /// Validates this instance. /// </summary> /// <returns>The Validate.</returns> public ValidationLog Validate() { var log = new ValidationLog(); foreach (var domain in this.Domains) { domain.Validate(log); } foreach (var unitType in this.Units) { unitType.Validate(log); } foreach (var @interface in this.Interfaces) { @interface.Validate(log); } foreach (var @class in this.Classes) { @class.Validate(log); } foreach (var inheritance in this.Inheritances) { inheritance.Validate(log); } foreach (var relationType in this.RelationTypes) { relationType.Validate(log); } foreach (var methodType in this.MethodTypes) { methodType.Validate(log); } var inheritancesBySubtype = new Dictionary<Composite, List<Inheritance>>(); foreach (var inheritance in this.Inheritances) { var subtype = inheritance.Subtype; if (subtype != null) { List<Inheritance> inheritanceList; if (!inheritancesBySubtype.TryGetValue(subtype, out inheritanceList)) { inheritanceList = new List<Inheritance>(); inheritancesBySubtype[subtype] = inheritanceList; } inheritanceList.Add(inheritance); } } var supertypes = new HashSet<Interface>(); foreach (var subtype in inheritancesBySubtype.Keys) { supertypes.Clear(); if (this.HasCycle(subtype, supertypes, inheritancesBySubtype)) { var message = subtype.ValidationName + " has a cycle in its inheritance hierarchy"; log.AddError(message, subtype, ValidationKind.Cyclic, "IComposite.Supertypes"); } } return log; }
/// <summary> /// Validates this instance. /// </summary> /// <param name="validationLog">The validation.</param> protected internal override void Validate(ValidationLog validationLog) { base.Validate(validationLog); if (!string.IsNullOrEmpty(this.SingularName)) { if (this.SingularName.Length < 2) { var message = this.ValidationName + " should have a singular name with at least 2 characters"; validationLog.AddError(message, this, ValidationKind.MinimumLength, "IObjectType.SingularName"); } else { if (!char.IsLetter(this.SingularName[0])) { var message = this.ValidationName + "'s singular name should start with an alfabetical character"; validationLog.AddError(message, this, ValidationKind.Format, "IObjectType.SingularName"); } for (var i = 1; i < this.SingularName.Length; i++) { if (!char.IsLetter(this.SingularName[i]) && !char.IsDigit(this.SingularName[i])) { var message = this.ValidationName + "'s singular name should only contain alfanumerical characters"; validationLog.AddError(message, this, ValidationKind.Format, "IObjectType.SingularName"); break; } } } if (validationLog.ExistObjectTypeName(this.SingularName)) { var message = "The singular name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "IObjectType.SingularName"); } else { validationLog.AddObjectTypeName(this.SingularName); } } else { validationLog.AddError(this.ValidationName + " has no singular name", this, ValidationKind.Required, "IObjectType.SingularName"); } if (!string.IsNullOrEmpty(this.PluralName)) { if (this.PluralName.Length < 2) { var message = this.ValidationName + " should have a plural name with at least 2 characters"; validationLog.AddError(message, this, ValidationKind.MinimumLength, "IObjectType.PluralName"); } else { if (!char.IsLetter(this.PluralName[0])) { var message = this.ValidationName + "'s plural name should start with an alfabetical character"; validationLog.AddError(message, this, ValidationKind.Format, "IObjectType.PluralName"); } for (var i = 1; i < this.PluralName.Length; i++) { if (!char.IsLetter(this.PluralName[i]) && !char.IsDigit(this.PluralName[i])) { var message = this.ValidationName + "'s plural name should only contain alfanumerical characters"; validationLog.AddError(message, this, ValidationKind.Format, "IObjectType.PluralName"); break; } } } if (validationLog.ExistObjectTypeName(this.PluralName)) { var message = "The plural name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "IObjectType.PluralName"); } else { validationLog.AddObjectTypeName(this.PluralName); } } }
/// <summary> /// Validates this instance. /// </summary> /// <param name="validationLog">The validation.</param> protected internal override void Validate(ValidationLog validationLog) { base.Validate(validationLog); if (!string.IsNullOrEmpty(this.SingularName)) { if (this.SingularName.Length < 2) { var message = this.ValidationName + " should have a singular name with at least 2 characters"; validationLog.AddError(message, this, ValidationKind.MinimumLength, "IObjectType.SingularName"); } else { if (!char.IsLetter(this.SingularName[0])) { var message = this.ValidationName + "'s singular name should start with an alfabetical character"; validationLog.AddError(message, this, ValidationKind.Format, "IObjectType.SingularName"); } for (var i = 1; i < this.SingularName.Length; i++) { if (!char.IsLetter(this.SingularName[i]) && !char.IsDigit(this.SingularName[i])) { var message = this.ValidationName + "'s singular name should only contain alfanumerical characters"; validationLog.AddError(message, this, ValidationKind.Format, "IObjectType.SingularName"); break; } } } if (validationLog.ExistObjectTypeName(this.SingularName)) { var message = "The singular name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "IObjectType.SingularName"); } else { validationLog.AddObjectTypeName(this.SingularName); } } else { validationLog.AddError(this.ValidationName + " has no singular name", this, ValidationKind.Required, "IObjectType.SingularName"); } if (!string.IsNullOrEmpty(this.PluralName)) { if (this.PluralName.Length < 2) { var message = this.ValidationName + " should have a plural name with at least 2 characters"; validationLog.AddError(message, this, ValidationKind.MinimumLength, "IObjectType.PluralName"); } else { if (!char.IsLetter(this.PluralName[0])) { var message = this.ValidationName + "'s plural name should start with an alfabetical character"; validationLog.AddError(message, this, ValidationKind.Format, "IObjectType.PluralName"); } for (var i = 1; i < this.PluralName.Length; i++) { if (!char.IsLetter(this.PluralName[i]) && !char.IsDigit(this.PluralName[i])) { var message = this.ValidationName + "'s plural name should only contain alfanumerical characters"; validationLog.AddError(message, this, ValidationKind.Format, "IObjectType.PluralName"); break; } } } if (validationLog.ExistObjectTypeName(this.PluralName)) { var message = "The plural name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "IObjectType.PluralName"); } else { validationLog.AddObjectTypeName(this.PluralName); } } else { validationLog.AddError(this.ValidationName + " has no plural name", this, ValidationKind.Required, "IObjectType.PluralName"); } }