Ejemplo n.º 1
0
        public void CheckTableScheme(TableScheme tableScheme)
        {
            Guard.NotNull(tableScheme, "tableScheme");

            if (!DatabaseValidation.IsValidFileName(tableScheme.Name))
            {
                throw new InvalidTableNameException("Table scheme has invalid name.");
            }

            if (tableScheme.Attributes.Count == 0)
            {
                throw new InvalidTableAttributesException("Table scheme has no attributes.");
            }

            HashSet <string> attributesNames = new HashSet <string>();

            try
            {
                foreach (Attribute attribute in tableScheme.Attributes)
                {
                    this.CheckAttribute(attribute);

                    if (attributesNames.Contains(attribute.Name))
                    {
                        throw new InvalidAttributeException($"Attribute's name \"{attribute.Name}\" is not unique.");
                    }
                    attributesNames.Add(attribute.Name);
                }
            }
            catch (InvalidAttributeException ex)
            {
                throw new InvalidTableAttributesException(
                          "Table scheme has invalid attribute. See inner exception for details.", ex);
            }
        }
Ejemplo n.º 2
0
        private void CheckAttribute(Attribute attribute)
        {
            Guard.NotNull(attribute, "attribute");

            if (!DatabaseValidation.IsValidFileName(attribute.Name))
            {
                throw new InvalidAttributeException($"Attribute's name \"{attribute.Name}\" is invalid.");
            }

            if (attribute.Type == null || !this._settings.DataTypes.ContainsKey(attribute.Type))
            {
                throw new InvalidAttributeException($"Attribute's type \"{attribute.Type}\" is unknown.");
            }
        }
Ejemplo n.º 3
0
 public bool IsValidDatabaseName(string dbName)
 {
     return(DatabaseValidation.IsValidFileName(dbName));
 }