/// <summary> /// Check that ids produced by resolver has valid format. /// </summary> /// <param name="properties">Properties that will be checked.</param> /// <param name="resolver">Resolver which produce id from traversed properties.</param> private static void checkIDsValidity(IEnumerable <PropertyInfo> properties, IDResolver resolver) { foreach (var property in properties) { var id = resolver(property); if (!isValidID(id)) { throw new IDValidationException( userMsg: "ID '{0}' detected on property '{1}' has incorrect format", developerMsg: "StructureValidation::checkIDsValidity ID '{0}' validation failed due to incorrect format in InfoAttribute on property '{1}'", validatedID: id, validatedProperty: property ); } } }
/// <summary> /// Check that ids produced by resolver are unique. /// </summary> /// <param name="properties">Properties that will be checked.</param> /// <param name="resolver">Resolver which produce id from traversed properties.</param> private static void checkIDUniqueness(IEnumerable <PropertyInfo> properties, IDResolver resolver) { var ids = new HashSet <string>(); foreach (var property in properties) { var id = resolver(property); if (!ids.Add(id)) { throw new IDValidationException( userMsg: "ID '{0}' detected on property '{1}' is duplicit", developerMsg: "StructureValidation::checkIDUniqueness ID '{0}' detected on property '{1}' has already been assigned to another property", validatedID: id, validatedProperty: property ); } } }